-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.py
39 lines (31 loc) · 1.02 KB
/
model.py
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
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Column, Integer, String, DateTime, func
from sqlalchemy import create_engine
db = SQLAlchemy()
def init_app(app):
db.app = app
db.init_app(app)
return db
def create_tables(app):
engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])
db.drop_all()
db.metadata.create_all(engine)
return engine
# Database Models
class SSMAgentList(db.Model):
__tablename__ = 'ssmlist'
profile = Column(String(30))
instance_id = Column(String(30), primary_key=True)
platform = Column(String(30))
tag_name = Column(String(20))
connect_port = Column(String(10))
updated_time = Column(DateTime(timezone=True), onupdate=func.now())
def to_json(self):
return {
'profile' : self.profile,
'instance_id': self.instance_id,
'platform': self.platform,
'tag_name':self.tag_name,
'connect_port': self.connect_port,
'updated_time': self.updated_time
}