【发布时间】:2018-03-09 05:59:47
【问题描述】:
我有一个特定的用例:
- 我正在使用 SQLAlchemy Core
- 我只想从
ResultsProxy到.fetchone() - 上下文管理器会自动关闭我的连接还是我必须手动关闭它?:
::
with engine.connect() as sqla_conn:
a_result_dict = dict(sqla_conn.execute(a_sqlalchemy_selectable).fetchone())
# will sqla_conn be closed after __exit__?
# or will it be kept open because the cursor may still have available rows to fetch?
【问题讨论】:
标签: python sqlalchemy contextmanager