2018-06-11 python-StatementError: (sqlalchemy.exc.InvalidRequestError) Can't reconnect until inva...

StatementError: (sqlalchemy.exc.InvalidRequestError) Can't reconnect until invalid transaction is rolled back

声明错误,在无效的事务被回滚之前不能重连。

当session中已经有了主键为A的对象,再次尝试将主键为A的对象加载到同一个会话中会导致出现这种错误。
因为会话机制要保证同一个会话中只能有一个主键为A的对象。
参考:
http://docs.sqlalchemy.org/en/rel_1_1/orm/tutorial.html

你可能感兴趣的:(2018-06-11 python-StatementError: (sqlalchemy.exc.InvalidRequestError) Can't reconnect until inva...)