Proxies a DBAPI connection and provides return-on-dereference support. This is an internal object used by the :class:`_pool.Pool` implementation to provide context management to a DBAPI connection delivered by that :class:`_pool.Pool`. The public facing interface for this class
| 1191 | |
| 1192 | |
| 1193 | class _ConnectionFairy(PoolProxiedConnection): |
| 1194 | """Proxies a DBAPI connection and provides return-on-dereference |
| 1195 | support. |
| 1196 | |
| 1197 | This is an internal object used by the :class:`_pool.Pool` implementation |
| 1198 | to provide context management to a DBAPI connection delivered by |
| 1199 | that :class:`_pool.Pool`. The public facing interface for this class |
| 1200 | is described by the :class:`.PoolProxiedConnection` class. See that |
| 1201 | class for public API details. |
| 1202 | |
| 1203 | The name "fairy" is inspired by the fact that the |
| 1204 | :class:`._ConnectionFairy` object's lifespan is transitory, as it lasts |
| 1205 | only for the length of a specific DBAPI connection being checked out from |
| 1206 | the pool, and additionally that as a transparent proxy, it is mostly |
| 1207 | invisible. |
| 1208 | |
| 1209 | .. seealso:: |
| 1210 | |
| 1211 | :class:`.PoolProxiedConnection` |
| 1212 | |
| 1213 | :class:`.ConnectionPoolEntry` |
| 1214 | |
| 1215 | |
| 1216 | """ |
| 1217 | |
| 1218 | __slots__ = ( |
| 1219 | "dbapi_connection", |
| 1220 | "_connection_record", |
| 1221 | "_echo", |
| 1222 | "_pool", |
| 1223 | "_counter", |
| 1224 | "__weakref__", |
| 1225 | "__dict__", |
| 1226 | ) |
| 1227 | |
| 1228 | pool: Pool |
| 1229 | dbapi_connection: DBAPIConnection |
| 1230 | _echo: log._EchoFlagType |
| 1231 | |
| 1232 | def __init__( |
| 1233 | self, |
| 1234 | pool: Pool, |
| 1235 | dbapi_connection: DBAPIConnection, |
| 1236 | connection_record: _ConnectionRecord, |
| 1237 | echo: log._EchoFlagType, |
| 1238 | ): |
| 1239 | self._pool = pool |
| 1240 | self._counter = 0 |
| 1241 | self.dbapi_connection = dbapi_connection |
| 1242 | self._connection_record = connection_record |
| 1243 | self._echo = echo |
| 1244 | |
| 1245 | _connection_record: Optional[_ConnectionRecord] |
| 1246 | |
| 1247 | @property |
| 1248 | def driver_connection(self) -> Optional[Any]: # type: ignore[override] # mypy#4125 # noqa: E501 |
| 1249 | if self._connection_record is None: |
| 1250 | return None |
no outgoing calls
no test coverage detected