class LocationModel(db.Model): """Docstring here.""" __tablename__ = "location" id = db.Column(db.Integer, primary_key=True) created_at = db.Column(db.DateTime, default=datetime.now) updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) barangay_id = db.Column(db.Integer, db.ForeignKey("barangay.id"), nullable=False) barangay = db.relationship(BarangayModel, backref="barangay", lazy=True) longitude = db.Column(CHAR(16), nullable=False) latitude = db.Column(CHAR(16), nullable=False) def __init__(self, barangay, longitude, latitude): self.barangay = barangay self.longitude = longitude self.latitude = latitude def json(self) -> dict: """JSON representation of the LocationModel.""" return {"id": self.id, "barangay": self.barangay.json()} @classmethod def find_by_id(cls, id: int) -> "LocationModel": return cls.query.filter_by(id=id).first() def remove_from_db(self): db.session.delete(self) db.session.comit()
class Unimac(BaseModel): __tablename__ = 'unimac' id = Column(Integer, primary_key=True, nullable=False) mac = Column(CHAR(20), nullable=False) manu = Column(CHAR(20), nullable=False) station = Column(CHAR(20), nullable=False) start_time = Column(DateTime, index=True, default=func.current_timestamp(), nullable=False) end_time = Column(DateTime, index=True, default=func.current_timestamp(), nullable=False) mid_time = Column(TIMESTAMP, default=func.current_timestamp(), nullable=False) flag = Column(UnicodeText) ap = Column(UnicodeText) ap_no_empty = Column(UnicodeText) def __repr__(self): return '<Unimac id : %r, mac : %r, start_time: %r, end_time: %r>' % ( self.id, self.mac, self.start_time, self.end_time) def get_eval(self, attr, default=None): if hasattr(self, attr) and getattr(self, attr): return eval(getattr(self, attr)) else: return default
class OmaQuota(BaseModel): __tablename__ = 'oma_quota' date = Column(Date, primary_key=True) investor_id = Column(CHAR(45), primary_key=True) symbol = Column(CHAR(45), primary_key=True) sell_quota = Column(Integer) buy_quota = Column(Integer)
class Strategy_Intraday_Parameter(BaseModel): __tablename__ = 'strategy_intraday_parameter' date = Column(Date, primary_key=True) strategy_name = Column(CHAR(100), primary_key=True) ticker = Column(CHAR(45), primary_key=True) parameter = Column(CHAR(45)) initial_share = Column(Integer)
class EventMetaDefaultModel(BaseModel): __tablename__ = 'eventmeta_default' id = Column(Integer, primary_key=True) app = Column(CHAR(100)) name = Column(CHAR(100)) type = Column(CHAR(100)) derived = Column(Integer) src_variableid = Column(CHAR(100)) properties = Column(VARCHAR(4000)) expire = Column(Integer) remark = Column(VARCHAR(1000)) last_modified = Column(Integer) config = Column(BLOB) def to_eventmeta(self): return EventMeta.from_json(self.config) @staticmethod def from_eventmeta(meta): return EventMetaDefaultModel(app=meta.app, name=meta.name, type=meta.type, derived=meta.derived, src_variableid=str(meta.src_variableid), properties=json.dumps( meta.get_dict()["properties"]), expire=meta.expire, last_modified=millis_now(), config=meta.get_json(), remark=meta.remark) def __str__(self): return str(self.__dict__)
class AppInfo(BaseModel): __tablename__ = 'server_info' server_ip = Column(CHAR(20), primary_key=True) server_name = Column(CHAR(40)) app_name = Column(CHAR(40)) start_file = Column(CHAR(40), primary_key=True) level = Column(Integer)
class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) uid = Column(CHAR(20), unique=True) name = Column(String(20)) sex = Column(String(20)) phone_number = Column(CHAR(11), unique=True) ID_card = Column(CHAR(18), unique=True) wx_id = Column(String(50), unique=True) email = Column(String(50), unique=True) credit = Column(Integer) credit_data = Column(CLOB) ceiling = Column(Float) owed = Column(Float) address = Column(String(100)) @classmethod def add_new_user(cls, phone_number): user = User(phone_number=phone_number) session.add(user) session.commit() return user @classmethod def get_user_by_phone_number(cls, phone_number): return session.query(cls).filter_by(phone_number=phone_number).first()
class LogParserModel(BaseModel): __tablename__ = 'logparser' id = Column(Integer, primary_key=True) source = Column(CHAR(100)) dest = Column(CHAR(100)) terms = Column(VARCHAR(4000)) host = Column(CHAR(100)) url = Column(CHAR(100)) remark = Column(VARCHAR(1000)) status = Column(Integer) last_modified = Column(Integer) @staticmethod def from_dict(logparser): return LogParserModel(source=logparser['source'], dest=logparser['dest'], terms=json.dumps(logparser['terms']), host=logparser.get('host', ''), url=logparser.get('url', ''), remark=logparser.get('remark', ''), status=logparser.get('status', 0), last_modified=millis_now()) def to_dict(self): return dict(id=self.id, source=self.source, dest=self.dest, terms=json.loads(self.terms), host=self.host, url=self.url, remark=self.remark, status=self.status)
class TagModel(BaseModel): __tablename__ = 'tags' id = Column(Integer, primary_key=True) app = Column(CHAR(100)) name = Column(CHAR(100)) last_modified = Column(Integer) def __str__(self): return str(self.__dict__) def to_tag(self): return { 'app': self.app, 'id': self.id, 'name': self.name, } @staticmethod def from_tag(tag): return TagModel( app=tag.get('app'), name=tag.get('name'), last_modified=millis_now(), )
class UserModel(BaseModel): __tablename__ = 'user' id = Column(Integer, primary_key=True) name = Column(CHAR(100)) password = Column(CHAR(100)) creator = Column(Integer) create_time = Column(Integer) last_login = Column(Integer) last_modified = Column(Integer) is_active = Column(Integer) @staticmethod def from_dict(user): return UserModel(name=user["name"], password=hashlib.sha1(user["password"]).hexdigest(), creator=user["creator"], create_time=user.get("create_time", millis_now()), last_login=user.get("last_login", 0), last_modified=user.get("last_modified", millis_now()), is_active=user.get("is_active", 0)) def to_dict(self): return dict(id=self.id, name=self.name, creator=self.creator, create_time=self.create_time, last_login=self.last_login, is_active=self.is_active)
class FutureMainContract(BaseModel): __tablename__ = 'future_main_contract' ticker_type = Column(CHAR(20), primary_key=True) exchange_id = Column(Integer, primary_key=True) pre_main_symbol = Column(CHAR(11)) main_symbol = Column(CHAR(11)) update_flag = Column(CHAR(11))
class Verification(Base): # 短信验证码及生成用户auth_key时间 __tablename__ = 'Verification' Vphone = Column(CHAR(11), primary_key=True) # Vcode = Column(CHAR(6), nullable=False) VT = Column(DateTime(timezone=True), default=func.now()) # 待测试是插入数据的时间还是最后一次更新该表的时间 (测试结果为第一次插入时间)
class PfAccount(BaseModel): __tablename__ = 'pf_account' id = Column(Integer) name = Column(CHAR(45), primary_key=True) fund_name = Column(CHAR(100), primary_key=True) group_name = Column(CHAR(45), primary_key=True) effective_date = Column(DateTime) description = Column(CHAR(1000))
class CountryInfoModel(Base): __tablename__ = 'country_info' __table_args__ = ( PrimaryKeyConstraint("iso_alpha2", "iso_alpha3"), ) iso_alpha2 = Column(CHAR(2), ForeignKey("geoname.country_code"), nullable=False) iso_alpha3 = Column(CHAR(3), nullable=False) geoname_id = Column(Integer, ForeignKey("geoname.geoname_id"))
class MainSubmainInfo(BaseModel): __tablename__ = 'main_submain' exchange_id = Column(CHAR(20)) undl_tickers = Column(CHAR(20)) start_date = Column(Date) end_date = Column(Date) main_contract = Column(CHAR(20), primary_key=True) sub_main_contract = Column(CHAR(20))
class AccountTradeRestrictions(BaseModel): __tablename__ = 'account_trade_restrictions' account_id = Column(Integer, primary_key=True) ticker = Column(CHAR(45), primary_key=True) exchange_id = Column(Integer, primary_key=True) hedgeflag = Column(CHAR(45), primary_key=True) max_open = Column(Integer) today_open = Column(Integer) max_cancel = Column(Integer) today_cancel = Column(Integer) max_large_cancel = Column(Integer) today_large_cancel = Column(Integer) max_operation = Column(Integer) today_operation = Column(Integer) option_max_long = Column(Integer) option_long = Column(Integer) option_max_short = Column(Integer) option_short = Column(Integer) max_order_flow_speed = Column(Integer) max_cancel_ratio_threshold = Column(Integer) max_cancel_ratio = Column(Float) min_fill_ratio_threshold = Column(Integer) min_fill_ratio_alarm = Column(Float) min_fill_ratio_block = Column(Float) max_buy_quota = Column(Float) today_rejected = Column(Integer) today_bid_amount = Column(Float) today_ask_amount = Column(Float) today_bid_canceled_amount = Column(Float) today_buy_amount = Column(Float) today_sell_amount = Column(Float) def __init__(self): self.max_open = 0 self.today_open = 0 self.max_cancel = 0 self.today_cancel = 0 self.max_large_cancel = 0 self.today_large_cancel = 0 self.max_operation = 0 self.today_operation = 0 self.option_max_long = 0 self.option_long = 0 self.option_max_short = 0 self.option_short = 0 def copy(self): return copy.deepcopy(self) def to_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class StrategyServerParameter(BaseModel): __tablename__ = 'strategy_server_parameter' date = Column(Date, primary_key=True) server_name = Column(CHAR(100), primary_key=True) strategy_name = Column(CHAR(100), primary_key=True) account_name = Column(CHAR(100), primary_key=True) max_long_position = Column(Integer) max_short_position = Column(Integer) qty_per_trade = Column(Integer)
class Tls209ApplnIpc(Base): __tablename__ = 'tls209_appln_ipc' appln_id = Column(INT, primary_key=True, default=0) ipc_class_symbol = Column(VARCHAR(15), primary_key=True, default='') ipc_class_level = Column(CHAR(1), default='') ipc_version = Column(DATE, default='9999-12-31') ipc_value = Column(CHAR(1), default='') ipc_position = Column(CHAR(1), default='') ipc_gener_auth = Column(CHAR(2), default='')
class StrategyChangeHistory(BaseModel): __tablename__ = 'strategy_change_history' id = Column(Integer, primary_key=True) enable = Column(Integer) name = Column(CHAR(45)) change_type = Column(CHAR(45)) # online/downline parameter_server = Column(CHAR(2000)) update_time = Column(DateTime) change_server_name = Column(CHAR(45))
class Tls803LegalEventCode(Base): __tablename__ = 'tls803_legal_event_code' event_auth = Column(CHAR(2), primary_key=True, default='') event_code = Column(VARCHAR(4), primary_key=True, default='') event_impact = Column(CHAR(1), default='') event_descr = Column(VARCHAR(250), default='') event_descr_orig = Column(VARCHAR(250), default='') event_category_code = Column(CHAR(1), default='') event_category_title = Column(VARCHAR(100), default='')
class Tls224ApplnCpc(Base): __tablename__ = 'tls224_appln_cpc' appln_id = Column(INT, primary_key=True, default=0) cpc_class_symbol = Column(VARCHAR(19), primary_key=True, default='') cpc_scheme = Column(VARCHAR(5), primary_key=True, default='') cpc_version = Column(DATE, default='9999-12-31') cpc_value = Column(CHAR(1), default='') cpc_position = Column(CHAR(1), default='') cpc_gener_auth = Column(CHAR(2), default='')
class AccountPosition(BaseModel): __tablename__ = 'account_position' date = Column(Date, primary_key=True) id = Column(Integer, primary_key=True) symbol = Column(CHAR(45), primary_key=True) hedgeflag = Column(CHAR(10), primary_key=True) long = Column(Float, default=0) long_cost = Column(Float, default=0) long_avail = Column(Float, default=0) day_long = Column(Float, default=0) day_long_cost = Column(Float, default=0) short = Column(Float, default=0) short_cost = Column(Float, default=0) short_avail = Column(Float, default=0) day_short = Column(Float, default=0) day_short_cost = Column(Float, default=0) fee = Column(Float, default=0) close_price = Column(Float) note = Column(CHAR(3600)) delta = Column(Float) gamma = Column(Float) theta = Column(Float) vega = Column(Float) rho = Column(Float) yd_position_long = Column(Float, default=0) yd_position_short = Column(Float, default=0) yd_long_remain = Column(Float, default=0) yd_short_remain = Column(Float, default=0) prev_net = Column(Float, default=0) purchase_avail = Column(Float, default=0) frozen = Column(Float, default=0) update_date = Column(DateTime, default=datetime.datetime) td_buy_long = 0 td_sell_short = 0 td_pur_red = 0 td_merge_split = 0 def __init__(self): self.td_buy_long = 0 self.td_sell_short = 0 self.td_pur_red = 0 self.td_merge_split = 0 self.long = 0 self.long_cost = 0.0 self.long_avail = 0 self.yd_position_long = 0 self.yd_long_remain = 0 self.short = 0 self.short_cost = 0.0 self.short_avail = 0 self.yd_position_short = 0 self.yd_short_remain = 0 def print_info(self): print 'yd_position_long:', self.yd_position_long, ',td_buy_long:', self.td_buy_long, \ ',td_sell_short:', self.td_sell_short,',td_pur_red:', self.td_pur_red, ',td_merge_split:', self.td_merge_split
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('modules', schema=None) as batch_op: batch_op.add_column(sa.Column('cc_uuid', CHAR(32), nullable=False)) batch_op.create_foreign_key('fk_modules_cc_uuid', 'cc_informations', ['cc_uuid'], ['uuid']) with op.batch_alter_table('schemas', schema=None) as batch_op: batch_op.add_column(sa.Column('cc_uuid', CHAR(32), nullable=False)) batch_op.create_foreign_key('fk_schemas_cc_uuid', 'cc_informations', ['cc_uuid'], ['uuid'])
class SBHash(Base): __tablename__ = 'sbclient_v4_hashes' hash = Column(CHAR(64), nullable=False, primary_key=True) prefix = Column(CHAR(64)) reflist_id = Column(INTEGER(unsigned=True), ForeignKey('sbclient_v4_lists.id'), nullable=False, primary_key=True) reflist = relationship('SBList', back_populates='hashes') __table_args__ = (UniqueConstraint('hash', 'reflist_id', name='_hash_reflist'), ForeignKeyConstraint([prefix, reflist_id], [SBPrefix.prefix, SBPrefix.reflist_id]),)
class Invit(BaseModel): __tablename__ = 'Invited' id = Column(Integer, primary_key=True, unique=True) Name = Column(CHAR(30)) Phone = Column(VARCHAR(13)) Invited = Column(VARCHAR(10)) # Time = Column(Time, default=datatime.now, nullable=False) Date = Column(CHAR(50)) Email = Column(VARCHAR(50)) Address = Column(VARCHAR(50))
class UserInfo(BaseModel): __tablename__ = 'user_info_table' user_id = Column(Integer, primary_key=True) telephone = Column(CHAR(11)) # or Column(String(30)) real_name = Column(CHAR(16)) nick_name = Column(CHAR(16)) password = Column(CHAR(64)) has_update = Column(Boolean(False)) id_number = Column(CHAR(18))
class Tls211PatPubln(Base): __tablename__ = 'tls211_pat_publn' pat_publn_id = Column(INT, primary_key=True, default=0) publn_auth = Column(CHAR(2), default='') publn_nr = Column(VARCHAR(15), default='') publn_nr_original = Column(VARCHAR(100), default='') publn_kind = Column(CHAR(2), default='') appln_id = Column(INT, default=0) publn_date = Column(DATE, default='9999-12-31') publn_lg = Column(CHAR(2), default='') publn_first_grant = Column(CHAR(1), default='N') publn_claims = Column(SMALLINT, default=0)
class Tls212Citation(Base): __tablename__ = 'tls212_citation' pat_publn_id = Column(INT, primary_key=True, default=0) citn_replenished = Column(INT, primary_key=True, default=0) citn_id = Column(SMALLINT, primary_key=True, default=0) citn_origin = Column(CHAR(3), default='') cited_pat_publn_id = Column(INT, default=0) cited_appln_id = Column(INT, default=0) pat_citn_seq_nr = Column(SMALLINT, default=0) cited_npl_publn_id = Column(INT, default=0) npl_citn_seq_nr = Column(SMALLINT, default=0) citn_gener_auth = Column(CHAR(2), default='')
class User(BaseModel): __tablename__ = 'eventmeta' id = Column(Integer, primary_key=True) name = Column(CHAR(100)) email = Column(CHAR(100)) password = Column(CHAR(40)) is_super = Column(Integer) attrs = Column(CHAR(3000)) last_login = Column(Integer, ) #上次登陆时间 date_joined = Column(Integer, ) #注册时间 is_active = Column(Integer) #是否激活,允许登陆
class DoubanNote(BaseModel): __tablename__ = 'doubannote' __table_args__ = { 'mysql_engine': 'InnoDB' } url = Column(CHAR(255), primary_key=True) title = Column(CHAR(255)) author = Column(CHAR(255)) tags = Column(CHAR(255)) snippet = Column(Text) comment_num = Column(Integer) pub_date = Column(TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'), nullable=False)