Close this :class:`_engine.Connection`. This results in a release of the underlying database resources, that is, the DBAPI connection referenced internally. The DBAPI connection is typically restored back to the connection-holding :class:`_pool.Pool` referenced
(self)
| 1219 | self._handle_dbapi_exception(e, None, None, None, None) |
| 1220 | |
| 1221 | def close(self) -> None: |
| 1222 | """Close this :class:`_engine.Connection`. |
| 1223 | |
| 1224 | This results in a release of the underlying database |
| 1225 | resources, that is, the DBAPI connection referenced |
| 1226 | internally. The DBAPI connection is typically restored |
| 1227 | back to the connection-holding :class:`_pool.Pool` referenced |
| 1228 | by the :class:`_engine.Engine` that produced this |
| 1229 | :class:`_engine.Connection`. Any transactional state present on |
| 1230 | the DBAPI connection is also unconditionally released via |
| 1231 | the DBAPI connection's ``rollback()`` method, regardless |
| 1232 | of any :class:`.Transaction` object that may be |
| 1233 | outstanding with regards to this :class:`_engine.Connection`. |
| 1234 | |
| 1235 | This has the effect of also calling :meth:`_engine.Connection.rollback` |
| 1236 | if any transaction is in place. |
| 1237 | |
| 1238 | After :meth:`_engine.Connection.close` is called, the |
| 1239 | :class:`_engine.Connection` is permanently in a closed state, |
| 1240 | and will allow no further operations. |
| 1241 | |
| 1242 | """ |
| 1243 | |
| 1244 | if self._transaction: |
| 1245 | self._transaction.close() |
| 1246 | skip_reset = True |
| 1247 | else: |
| 1248 | skip_reset = False |
| 1249 | |
| 1250 | if self._dbapi_connection is not None: |
| 1251 | conn = self._dbapi_connection |
| 1252 | |
| 1253 | # as we just closed the transaction, close the connection |
| 1254 | # pool connection without doing an additional reset |
| 1255 | if skip_reset: |
| 1256 | cast("_ConnectionFairy", conn)._close_special( |
| 1257 | transaction_reset=True |
| 1258 | ) |
| 1259 | else: |
| 1260 | conn.close() |
| 1261 | |
| 1262 | # There is a slight chance that conn.close() may have |
| 1263 | # triggered an invalidation here in which case |
| 1264 | # _dbapi_connection would already be None, however usually |
| 1265 | # it will be non-None here and in a "closed" state. |
| 1266 | self._dbapi_connection = None |
| 1267 | self.__can_reconnect = False |
| 1268 | |
| 1269 | @overload |
| 1270 | def scalar( |
no test coverage detected