注册

SQLAlchemy带自增列插入数据时不起作用

日出东方 2023/04/08 1185 2

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:8
【操作系统】:Win11
【CPU】:
【问题描述】*:SQLAlchemy框架下,表自增列为id,插入数据时,id 不赋值,报错:sqlalchemy.orm.exc.FlushError: Instance <Contract at 0x28eb8ab65d0> has a NULL identity key. If this is an auto-generated value, check that the database table allows generation of new primary key values, and that the mapped Column object is configured to expect these generated values. Ensure also that this flush() is not occurring at an inappropriate time, such as within a load() event,数据没有插入成功,但是在sql下使用sql语句插入,ID不赋值可以成功插入数据,该怎么操作?

回答 0
暂无回答
扫一扫
联系客服