急寻解决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()事件中。