How to close a SQLAlchemy session?

后端 未结 3 1473
迷失自我
迷失自我 2020-12-04 09:55

Following what we commented in How to close sqlalchemy connection in MySQL, I am checking the connections that SQLAlchemy creates into my database and I cannot manage to clo

3条回答
  •  [愿得一人]
    2020-12-04 10:34

    session.close() will give the connection back to the connection pool of Engine and doesn't close the connection.

    engine.dispose() will close all connections of the connection pool.

    Engine will not use connection pool if you set poolclass=NullPool. So the connection (SQLAlchemy session) will close directly after session.close().

提交回复
热议问题