如何在创建表之后向SQLAlchemy模型添加索引和模式

2024-04-24 19:21:34 发布

您现在位置:Python中文网/ 问答频道 /正文

代码如下:

Base = declarative_base()
metadata = Base.metadata
session = None

class TCmcDatum(Base):
    __tablename__ = 't_cmc_data'
    __table_args__ = (
        Index('i_cmc_data_ctime_name', 'c_time', 'slug', unique=True),
    )
    __table_args__ = {'schema':'crawler'}

    id = Column(BIGINT(20), primary_key=True, comment='autoincr id')
    c_time = Column(BIGINT(13), nullable=False, comment='created time')

当然,它解决不了问题

如何纠正?谢谢


Tags: 代码idtruedatabasetimetablecomment