-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_definition.py
More file actions
39 lines (24 loc) · 847 Bytes
/
db_definition.py
File metadata and controls
39 lines (24 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import connexion
import datetime
from flask_sqlalchemy import sqlalchemy, SQLAlchemy
db_name = "iskam.db"
app = connexion.App(__name__, specification_dir='./swagger/')
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{db}'.format(db=db_name)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
def _get_date():
return datetime.datetime.now()
class MovementRoutes(db.Model):
__tablename__ = 'movement_routes'
id = db.Column(db.Integer, primary_key=True)
source = db.Column(db.String)
destination = db.Column(db.String)
batch = db.Column(db.String)
transformation = db.Column(db.String)
type = db.Column(db.String)
added = db.Column(db.Date, default=_get_date)
tables = db.Column(db.String)
def create_db():
db.create_all()
if __name__ == '__main__':
create_db()