SQLALCHEMY的MODE
class FutureTradeBlanceHis(Base):
"""Marex余额变更历史记录"""
tablename = "T_FutureTrade_Blance_History"
table_args = (
(ForeignKeyConstraint(['blanceid', 'contractid'],
['T_FutureTrade_Blance.pid','T_FutureTrade_Blance.contractid'])
),
) #多外键范例
pid = Column(Integer, primary_key=True)
blanceid = Column(Integer)#,
chagedate = Column(Date) # 更新时间
marketid = Column(String(50)) # 市场代码
contractid = Column(String(50)) # 合约号
direction = Column(String(50)) # 多空方向
buyblance = Column(Float) # 买入余额
sellblance = Column(Float) # 卖出余额
totalblance = Column(Float) # 总余额
多外键的MODE设置
class FutureTradeBlance(Base):
tablename = "T_FutureTrade_Blance"
table_args = ((PrimaryKeyConstraint('pid', 'contractid')),) #建立多主键的方式
pid = Column(Integer)
sourceid = Column(String(50)) #系统代码
marketid = Column(String(50)) # 市场代码
contractid = Column(String(50)) # 合约号
createdate = Column(Date) #创建时间
updatedate = Column(Date) #更新时间
direction = Column(String(50)) # 多空方向
buyblance = Column(Float) # 买入余额
sellblance = Column(Float) # 卖出余额
totalblance = Column(Float) # 总余额
多主键的模型类建立
网友评论