我有一个与sqlalchemy和postgresql相关的问题.
class Profile(Base):
...
roles = relationship('Role', secondary=role_profiles,
backref='profiles', lazy='dynamic')
Run Code Online (Sandbox Code Playgroud)
运行时(current_user是Profile类的实例):
roles = current_user.roles.filter().all()
Run Code Online (Sandbox Code Playgroud)
使用sqlalchemy我得到idle in transaction了所有选择,以便在postgresql中读取配置文件.
编辑:
从回显查询中我看到每个选择都以:
BEGIN (implicit)
Run Code Online (Sandbox Code Playgroud)
另一个编辑:
添加后
pool_size=20, max_overflow=0
Run Code Online (Sandbox Code Playgroud)
在create_engine它好像idle in transaction-statements被回滚时空闲的数量越来越变大.有任何想法,这将是一个解决问题的坏方法吗?
我如何管理这个以及如何摆脱BEGIN选择呢?