SQLAlchemy Layer - The Connection Pool说明

请添加图片描述

A connection pool is a standard technique used to maintain long running connections in memory for efficient re-use, as well as to provide management for the total number of connections an application might use simultaneously.

With the connection pool, the opening and closing of connections and which connection you are using when you’re executing statements within a session is completely abstracted away from you.

  • Uses a connection pool to easily reuse existing connections.
    • Avoid opening and closing connections for every data change.
    • Handles dropped connections.
    • Avoid doing very many small calls to the DB (very slow)

Particularly for server-side web applications, a connection pool is the standard way to maintain a “pool” of active database connections in memory which are reused across requests.

SQLAlchemy includes several connection pool implementations which integrate with the Engine. They can also be used directly for applications that want to add pooling to an otherwise plain DBAPI approach.

猜你喜欢

转载自blog.csdn.net/BSCHN123/article/details/121220098