MCPcopy Index your code
hub / github.com/tortoise/tortoise-orm / get_connection

Function get_connection

tortoise/connection.py:315–327  ·  view source on GitHub ↗

Get a database connection by alias from the current context. This is a convenience function. Prefer accessing connections directly via context: `ctx.connections.get(alias)` :param alias: The connection alias (e.g., "default") :raises ConfigurationError: If no context is active

(alias: str)

Source from the content-addressed store, hash-verified

313
314
315def get_connection(alias: str) -> BaseDBAsyncClient:
316 """
317 Get a database connection by alias from the current context.
318
319 This is a convenience function. Prefer accessing connections directly
320 via context: `ctx.connections.get(alias)`
321
322 :param alias: The connection alias (e.g., "default")
323 :raises ConfigurationError: If no context is active or connection not found
324 """
325 from tortoise.context import require_context
326
327 return require_context().connections.get(alias)
328
329
330def get_connections() -> ConnectionHandler:

Callers 8

get_connectionMethod · 0.90
dbMethod · 0.90
_db_routeMethod · 0.90
check_capabilitiesFunction · 0.90
historyFunction · 0.90
planFunction · 0.90
sqlmigrateFunction · 0.90
migrateFunction · 0.90

Calls 2

require_contextFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…