![](/img/trans.png)
[英]create column not primary key but identity on sqlalchemy for sql server
[英]How to create an identity column not being a primary key with SQLAlchemy?
如何在SQLAlchemy中创建一个标识列,使其自身自动递增而不是主键?
我正在使用Postgres。
谢谢,
晏
这样的事情应该起作用。
table_sequence = Sequence('table_id_seq', start=1)
class MyTable(Base):
__tablename__ = 'mytable'
id = Column(Integer, table_sequence, server_default=table_sequence.next_value())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.