急寻解决Instance has a NULL identity key.报错

行則將至 2019-06-05 11:26:08
def User(xx, xx, xx, xx, xx):
station_res = session.query(X.xx).filter(
X.xx== xx,
X.xx== xx,
X.xx== xx,
X.xx== xx,
X.xx != None
).first()


调用User这个函数时报错如下:

Instance <User at 0x27a9930> 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.

翻译如下:# instance<machine_data_history at 0x27A9930>具有空标识密钥。如果这是自动生成的值,请检查数据库表是否允许生成新的主键值,以及映射的列对象是否配置为期望这些生成的值。还要确保此flush()不会在不适当的时间发生,例如在load()事件中。
...全文
221 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

37,722

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧