Abstract base class for connection pools.
| 154 | |
| 155 | |
| 156 | class Pool(log.Identified, event.EventTarget): |
| 157 | """Abstract base class for connection pools.""" |
| 158 | |
| 159 | dispatch: dispatcher[Pool] |
| 160 | echo: log._EchoFlagType |
| 161 | |
| 162 | _orig_logging_name: Optional[str] |
| 163 | _dialect: Union[_ConnDialect, Dialect] = _ConnDialect() |
| 164 | _creator_arg: Union[_CreatorFnType, _CreatorWRecFnType] |
| 165 | _invoke_creator: _CreatorWRecFnType |
| 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 |
nothing calls this directly
no test coverage detected