我使用SQLAlchemy将一行插入表中。表的定义如下:
class MyTable():
__table__ = "my_table"
id = Column(BigInteger, primary_key=True)
stuff1 = Column(Numeric)
以下是炼金术:
^{pr2}$下面是它生成的查询:
INSERT INTO my_table (id, stuff1) VALUES (null, 100)
我得到一个错误:
IntegrityError('(psycopg2.IntegrityError) null value in column \"id\" violates not-null constraint
主键是自动生成的,因为它是自动生成的。但似乎我必须手动对其应用一个序列?我做错什么了?在
目前没有回答
相关问题 更多 >
编程相关推荐