MCPcopy
hub / github.com/django/django / ensure_connection

Method ensure_connection

django/db/backends/base/base.py:271–279  ·  view source on GitHub ↗

Guarantee that a connection to the database is established.

(self)

Source from the content-addressed store, hash-verified

269
270 @async_unsafe
271 def ensure_connection(self):
272 """Guarantee that a connection to the database is established."""
273 if self.connection is None:
274 if self.in_atomic_block and self.closed_in_transaction:
275 raise ProgrammingError(
276 "Cannot open a new connection in an atomic block."
277 )
278 with self.wrap_database_errors:
279 self.connect()
280
281 # ##### Backend-specific wrappers for PEP-249 connection methods #####
282

Callers 15

_cursorMethod · 0.95
get_autocommitMethod · 0.95
set_autocommitMethod · 0.95
__enter__Method · 0.80
max_query_paramsMethod · 0.80
quote_valueMethod · 0.80
create_test_dbMethod · 0.80

Calls 2

connectMethod · 0.95
ProgrammingErrorClass · 0.90