MCPcopy
hub / github.com/tortoise/tortoise-orm / _get_connection

Function _get_connection

tortoise/transactions.py:18–30  ·  view source on GitHub ↗
(connection_name: str | None)

Source from the content-addressed store, hash-verified

16
17
18def _get_connection(connection_name: str | None) -> BaseDBAsyncClient:
19 conn_handler = get_connections()
20 if connection_name:
21 connection = conn_handler.get(connection_name)
22 elif len(conn_handler.db_config) == 1:
23 connection_name = next(iter(conn_handler.db_config.keys()))
24 connection = conn_handler.get(connection_name)
25 else:
26 raise ParamsError(
27 "You are running with multiple databases, so you should specify"
28 f" connection_name: {list(conn_handler.db_config)}"
29 )
30 return connection
31
32
33def in_transaction(connection_name: str | None = None) -> TransactionContext:

Callers 1

in_transactionFunction · 0.85

Calls 4

get_connectionsFunction · 0.90
ParamsErrorClass · 0.90
keysMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…