Acquire a database connection from the pool. :param float timeout: A timeout for acquiring a Connection. :return: An instance of :class:`~asyncpg.connection.Connection`. Can be used in an ``await`` expression or with an ``async with`` block. .. code-block:: python
(self, *, timeout=None)
| 967 | ) |
| 968 | |
| 969 | def acquire(self, *, timeout=None): |
| 970 | """Acquire a database connection from the pool. |
| 971 | |
| 972 | :param float timeout: A timeout for acquiring a Connection. |
| 973 | :return: An instance of :class:`~asyncpg.connection.Connection`. |
| 974 | |
| 975 | Can be used in an ``await`` expression or with an ``async with`` block. |
| 976 | |
| 977 | .. code-block:: python |
| 978 | |
| 979 | async with pool.acquire() as con: |
| 980 | await con.execute(...) |
| 981 | |
| 982 | Or: |
| 983 | |
| 984 | .. code-block:: python |
| 985 | |
| 986 | con = await pool.acquire() |
| 987 | try: |
| 988 | await con.execute(...) |
| 989 | finally: |
| 990 | await pool.release(con) |
| 991 | """ |
| 992 | return PoolAcquireContext(self, timeout) |
| 993 | |
| 994 | async def _acquire(self, timeout): |
| 995 | async def _acquire_impl(): |