class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(200)) password = db.Column(db.String(200)) email = db.Column(db.String(200), unique=True) mobile = db.Column(db.String(20)) def __str__(self): return self.email
class TaskCaseResult(db.Model): __tablename__ = 'task_case_result' id = db.Column(db.Integer, primary_key=True) task_case_id = db.Column(db.Integer) task_execution_id = db.Column(db.Integer) current_status = db.Column(db.String(50)) execution_start = db.Column(db.DateTime, nullable=True) execution_end = db.Column(db.DateTime, nullable=True) source_result = db.Column(db.Text) destination_result = db.Column(db.Text) diff = db.Column(db.Text) result_message = db.Column(db.Text)
class TaskScenarios(db.Model): __tablename__ = 'task_scenarios' id = db.Column(db.Integer, primary_key=True) task_scenarios_name = db.Column(db.String(1000)) description = db.Column(db.String(1000)) group_list = db.relationship('src.www.models.task_group.TaskGroup', secondary=group_scenarios, backref=db.backref('group_list', lazy='dynamic')) owner_id = db.Column(db.Integer, db.ForeignKey('user.id')) owner = db.relationship( 'src.www.models.user.User', foreign_keys=[owner_id]) is_enabled = db.Column(db.Integer) def __str__(self): return self.task_scenarios_name
class DbConnect(db.Model): __tablename__ = 'db_connect' id = db.Column(db.Integer, primary_key=True) db_connect_name = db.Column(db.String(200), unique=True) db_connect_type = db.Column(db.Integer) host = db.Column(db.String(200)) port = db.Column(db.Integer) username = db.Column(db.String(200)) password = db.Column(db.String(200)) db_name = db.Column(db.String(200)) def __str__(self): return self.db_connect_name
class TaskExecution(db.Model): __tablename__ = 'task_execution' id = db.Column(db.Integer, primary_key=True) execution_type = db.Column(db.String(50)) execution_name = db.Column(db.String(1000)) current_status = db.Column(db.String(50)) execution_start = db.Column(db.DateTime, nullable=True) execution_end = db.Column(db.DateTime, nullable=True)
class EmailTemplate(db.Model): __tablename__ = 'email_template' id = db.Column(db.Integer, primary_key=True) email_subject = db.Column(db.String(200), unique=True) msg_template = db.Column((db.Text)) email_to = db.Column(db.String(4000), nullable=False) email_cc = db.Column(db.String(4000), nullable=True) email_bcc = db.Column(db.String(4000), nullable=True) description = db.Column(db.String(1000), nullable=True) def __str__(self): return self.email_subject
import datetime from flask_admin.contrib.sqla import ModelView from wtforms import SelectField from src.www.orm import db # Define models case_group = db.Table( 'case_group', db.Column('task_case_id', db.Integer(), db.ForeignKey('task_case.id')), db.Column('task_group_id', db.Integer(), db.ForeignKey('task_group.id'))) class TaskGroup(db.Model): __tablename__ = 'task_group' id = db.Column(db.Integer, primary_key=True) task_group_name = db.Column(db.String(1000)) description = db.Column(db.String(1000)) case_list = db.relationship('src.www.models.task_case.TaskCase', secondary=case_group, backref=db.backref('case_list', lazy='dynamic')) owner_id = db.Column(db.Integer, db.ForeignKey('user.id')) owner = db.relationship('src.www.models.user.User', foreign_keys=[owner_id]) is_enabled = db.Column(db.Integer) def __str__(self): return self.task_group_name class TaskGroupModelView(ModelView):
import datetime from flask_admin.contrib.sqla import ModelView from wtforms import SelectField from src.www.orm import db # Define models group_scenarios = db.Table( 'group_scenarios', db.Column('task_group_id', db.Integer(), db.ForeignKey('task_group.id')), db.Column('task_scenarios_id', db.Integer(), db.ForeignKey('task_scenarios.id')) ) class TaskScenarios(db.Model): __tablename__ = 'task_scenarios' id = db.Column(db.Integer, primary_key=True) task_scenarios_name = db.Column(db.String(1000)) description = db.Column(db.String(1000)) group_list = db.relationship('src.www.models.task_group.TaskGroup', secondary=group_scenarios, backref=db.backref('group_list', lazy='dynamic')) owner_id = db.Column(db.Integer, db.ForeignKey('user.id')) owner = db.relationship( 'src.www.models.user.User', foreign_keys=[owner_id]) is_enabled = db.Column(db.Integer) def __str__(self): return self.task_scenarios_name class TaskScenariosModelView(ModelView): page_size = 15
class TaskCase(db.Model): __tablename__ = 'task_case' id = db.Column(db.Integer, primary_key=True) task_case_name = db.Column(db.String(1000), nullable=False, unique=True) alias = db.Column(db.String(1000), nullable=True) description = db.Column(db.String(1000), nullable=True) source_sql = db.Column(db.Text, nullable=True) destination_sql = db.Column(db.Text, nullable=True) source_connect_id = db.Column(db.Integer, db.ForeignKey('db_connect.id'), nullable=True) source_connect = db.relationship( 'src.www.models.db_connect.DbConnect', foreign_keys=[source_connect_id]) destination_connect_id = db.Column( db.Integer, db.ForeignKey('db_connect.id'), nullable=True) destination_connect = db.relationship( 'src.www.models.db_connect.DbConnect', foreign_keys=[destination_connect_id]) is_enabled = db.Column(db.Integer,nullable=False) match_type = db.Column(db.Integer,nullable=False) threshlod_low = db.Column(db.Integer, nullable=True) threshlod_high = db.Column(db.Integer, nullable=True) duration_limit = db.Column(db.Integer) last_run = db.Column(db.DateTime, nullable=True) owner_id = db.Column(db.Integer, db.ForeignKey('user.id')) owner = db.relationship( 'src.www.models.user.User', foreign_keys=[owner_id]) email_template_id = db.Column(db.Integer, db.ForeignKey('email_template.id')) email_template = db.relationship( 'src.www.models.email_template.EmailTemplate', foreign_keys=[email_template_id]) def __str__(self): return self.task_case_name