Construct a Pool. :param creator: a callable function that returns a DB-API connection object. The function will be called with parameters. :param recycle: If set to a value other than -1, number of seconds between connection recycling, which
(
self,
creator: Union[_CreatorFnType, _CreatorWRecFnType],
recycle: int = -1,
echo: log._EchoFlagType = None,
logging_name: Optional[str] = None,
reset_on_return: _ResetStyleArgType = True,
events: Optional[List[Tuple[_ListenerFnType, str]]] = None,
dialect: Optional[Union[_ConnDialect, Dialect]] = None,
pre_ping: bool = False,
_dispatch: Optional[_DispatchCommon[Pool]] = None,
)
| 166 | _invalidate_time: float |
| 167 | |
| 168 | def __init__( |
| 169 | self, |
| 170 | creator: Union[_CreatorFnType, _CreatorWRecFnType], |
| 171 | recycle: int = -1, |
| 172 | echo: log._EchoFlagType = None, |
| 173 | logging_name: Optional[str] = None, |
| 174 | reset_on_return: _ResetStyleArgType = True, |
| 175 | events: Optional[List[Tuple[_ListenerFnType, str]]] = None, |
| 176 | dialect: Optional[Union[_ConnDialect, Dialect]] = None, |
| 177 | pre_ping: bool = False, |
| 178 | _dispatch: Optional[_DispatchCommon[Pool]] = None, |
| 179 | ): |
| 180 | """ |
| 181 | Construct a Pool. |
| 182 | |
| 183 | :param creator: a callable function that returns a DB-API |
| 184 | connection object. The function will be called with |
| 185 | parameters. |
| 186 | |
| 187 | :param recycle: If set to a value other than -1, number of |
| 188 | seconds between connection recycling, which means upon |
| 189 | checkout, if this timeout is surpassed the connection will be |
| 190 | closed and replaced with a newly opened connection. Defaults to -1. |
| 191 | |
| 192 | :param logging_name: String identifier which will be used within |
| 193 | the "name" field of logging records generated within the |
| 194 | "sqlalchemy.pool" logger. Defaults to a hexstring of the object's |
| 195 | id. |
| 196 | |
| 197 | :param echo: if True, the connection pool will log |
| 198 | informational output such as when connections are invalidated |
| 199 | as well as when connections are recycled to the default log handler, |
| 200 | which defaults to ``sys.stdout`` for output.. If set to the string |
| 201 | ``"debug"``, the logging will include pool checkouts and checkins. |
| 202 | |
| 203 | The :paramref:`_pool.Pool.echo` parameter can also be set from the |
| 204 | :func:`_sa.create_engine` call by using the |
| 205 | :paramref:`_sa.create_engine.echo_pool` parameter. |
| 206 | |
| 207 | .. seealso:: |
| 208 | |
| 209 | :ref:`dbengine_logging` - further detail on how to configure |
| 210 | logging. |
| 211 | |
| 212 | :param reset_on_return: Determine steps to take on |
| 213 | connections as they are returned to the pool, which were |
| 214 | not otherwise handled by a :class:`_engine.Connection`. |
| 215 | Available from :func:`_sa.create_engine` via the |
| 216 | :paramref:`_sa.create_engine.pool_reset_on_return` parameter. |
| 217 | |
| 218 | :paramref:`_pool.Pool.reset_on_return` can have any of these values: |
| 219 | |
| 220 | * ``"rollback"`` - call rollback() on the connection, |
| 221 | to release locks and transaction resources. |
| 222 | This is the default value. The vast majority |
| 223 | of use cases should leave this value set. |
| 224 | * ``"commit"`` - call commit() on the connection, |
| 225 | to release locks and transaction resources. |