initial database model
This commit is contained in:
parent
cd5a1f3f4a
commit
98adec9ead
3 changed files with 38 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -58,3 +58,5 @@ docs/_build/
|
|||
# PyBuilder
|
||||
target/
|
||||
|
||||
# my other cruft
|
||||
*.yaml
|
17
manage.py
Normal file
17
manage.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import yaml
|
||||
from appservice import app
|
||||
from models import *
|
||||
from flask_script import Manager
|
||||
from flask_migrate import Migrate, MigrateCommand
|
||||
|
||||
migrate = Migrate(app, db)
|
||||
|
||||
manager = Manager(app)
|
||||
manager.add_command('db', MigrateCommand)
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open("config.yaml", "rb") as config_file:
|
||||
config = yaml.load(config_file)
|
||||
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = config['SQLALCHEMY_DATABASE_URI']
|
||||
manager.run()
|
19
models.py
Normal file
19
models.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
||||
|
||||
class MatrixUser(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
matrix_id = db.Column(db.Text, unique=True)
|
||||
room_id = db.Column(db.Text)
|
||||
pnut_id = db.Column(db.Text, unique=True)
|
||||
pnut_token = db.Column(db.Text)
|
||||
|
||||
def __init__(self, matrix_id, room_id, pnut_id, pnut_token):
|
||||
self.matrix_id = matrix_id
|
||||
self.room_id = room_id
|
||||
self.pnut_id = pnut_id
|
||||
self.pnut_token = pnut_token
|
||||
|
||||
def __repr__(self):
|
||||
return '<MatrixUser %r' % self.matrix_id
|
Loading…
Reference in a new issue