SQLAlchemy: prevent automatic closing
问题 I need to insert/update bulk rows via SQLAlchemy. And get inserted rows. I tried to do it with session.execute: >>> posts = db.session.execute(Post.__table__.insert(), [{'title': 'dfghdfg', 'content': 'sdfgsdf', 'topic': topic}]*2) >>> posts.fetchall() ResourceClosedError Traceback (most recent call last) And with engine: In [17]: conn = db.engine.connect() In [18]: result = conn.execute(Post.__table__.insert(), [{'title': 'title', 'content': 'content', 'topic': topic}]*2) In [19]: print