Get a connection from the pool. If inside a transaction, returns the transaction connection.
(self)
| 109 | |
| 110 | @asynccontextmanager |
| 111 | async def connection(self) -> AsyncIterator[AsyncConnection]: |
| 112 | """ |
| 113 | Get a connection from the pool. |
| 114 | If inside a transaction, returns the transaction connection. |
| 115 | """ |
| 116 | trans_conn = _transaction_connection.get() |
| 117 | if trans_conn is not None: |
| 118 | yield trans_conn |
| 119 | else: |
| 120 | async with self.engine.connect() as conn: |
| 121 | yield conn |
| 122 | |
| 123 | def transaction(self, force_rollback: bool = False) -> Transaction: |
| 124 | """ |