![](/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.