Exemple #1
0
class User_Group(db.Model):
    __tablename__ = 'user_group'
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment="用户组ID")
    group_name = db.Column(db.String(32),nullable=False,default='',server_default='',unique=True,comment="组名称")
    users = db.relationship('User',backref='group')
    introduction = db.Column(db.String(16),nullable=False,default='',server_default='',comment="用户组简介")
    add_time = db.Column(db.DateTime,default=datetime.now,comment="添加时间")
    last_modify_time  = db.Column(db.DateTime,default=datetime.now,onupdate=datetime.now,comment="最后更新时间")
    def __repr__(self):
        return '<User_Group %r>' % (self.group_name)
Exemple #2
0
class Data_Center(db.Model):
    __tablename__ = "data_center"
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment="数据中心ID")
    name = db.Column(db.String(32),unique=True,nullable=False,default='',server_default='',comment="数据中心名称")
    introduction = db.Column(db.String(64),nullable=False,default='',server_default='',comment="数据中心简介")
    add_time = db.Column(db.DateTime,default=datetime.now,comment="添加时间")
    last_modify_time  = db.Column(db.DateTime,default=datetime.now,onupdate=datetime.now,comment="最后更新时间")
    databases = db.relationship('MySQL_Databases',backref='data_center')
    def __repr__(self):
        return  '<Data_Center %r>' % (self.name)
Exemple #3
0
class Db_Cluster(db.Model):
    __tablename__ = "db_cluster"
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment="集群主键ID")
    name = db.Column(db.String(64),nullable=False,default='',server_default='',index=True,unique=True,comment="名称")
    status = db.Column(db.String(6),nullable=False,default="online",server_default="online",comment="状态")
    introduction = db.Column(db.String(256),nullable=False,default='',server_default='',comment="简介")
    applicant = db.Column(db.String(16),nullable=False,default='',server_default='',index=True,comment="who applicate this cluster")
    add_time = db.Column(db.DateTime,default=datetime.now,comment="添加时间")
    last_modify_time  = db.Column(db.DateTime,default=datetime.now,onupdate=datetime.now,comment="最后更新时间")
    databases = db.relationship('MySQL_Databases', backref='cluster')
    def __repr__(self):
        return  '<Db_Cluster %r>' % (self.name)
Exemple #4
0
class Data_Center(db.Model):
    __tablename__ = "data_center"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(32), unique=True)
    introduction = db.Column(db.String(64))
    add_time = db.Column(db.DateTime, default=datetime.now())
    last_modify_time = db.Column(db.DateTime,
                                 default=datetime.now(),
                                 onupdate=datetime.now())
    databases = db.relationship('MySQL_Databases', backref='data_center')

    def __repr__(self):
        return '<Data_Center %r>' % (self.name)
Exemple #5
0
class MySQL_Databases(db.Model):
    __tablename__ = 'mysql_databases'
    id = db.Column(db.Integer,
                   primary_key=True,
                   autoincrement=True,
                   comment="主键ID")
    name = db.Column(db.String(32), index=True, unique=True, comment="名称(标识)")
    cluster_id = db.Column(db.Integer,
                           db.ForeignKey('db_cluster.id'),
                           comment="集群ID")
    datacenter_id = db.Column(db.Integer,
                              db.ForeignKey('data_center.id'),
                              comment="所属数据库中心")
    version = db.Column(db.String(16),
                        nullable=False,
                        default='',
                        comment="版本号")
    ip = db.Column(db.String(16), nullable=False, index=True, comment="IP地址")
    port = db.Column(db.Integer, nullable=False, comment="端口")
    is_master = db.Column(db.SmallInteger,
                          nullable=False,
                          default=0,
                          comment="是否主库,0否1是")
    is_slave = db.Column(db.SmallInteger,
                         nullable=False,
                         default=0,
                         comment="是否从库,0否1是")
    status = db.Column(db.String(10),
                       nullable=False,
                       default='unknown',
                       comment="active:正常,inactive:出错,unknown:未知状态")
    applicant = db.Column(db.String(16), nullable=False, comment="申请人")
    introduction = db.Column(db.String(8), comment="说明简介")
    add_time = db.Column(db.DateTime, default=datetime.now())
    last_modify_time = db.Column(db.DateTime,
                                 default=datetime.now(),
                                 onupdate=datetime.now())
    tickets = db.relationship('Tickets', backref='mysql_databases')

    def __repr__(self):
        return '<Databases %r>' % (self.name)