MCPcopy Index your code
hub / github.com/reflex-dev/reflex / get_engine_args

Function get_engine_args

reflex/model.py:63–87  ·  view source on GitHub ↗

Get the database engine arguments. Args: url: The database url. Returns: The database engine arguments as a dict.

(url: str | None = None)

Source from the content-addressed store, hash-verified

61 _ASYNC_ENGINE: dict[str, sqlalchemy.ext.asyncio.AsyncEngine] = {}
62
63 def get_engine_args(url: str | None = None) -> dict[str, Any]:
64 """Get the database engine arguments.
65
66 Args:
67 url: The database url.
68
69 Returns:
70 The database engine arguments as a dict.
71 """
72 kwargs: dict[str, Any] = {
73 # Print the SQL queries if the log level is INFO or lower.
74 "echo": environment.SQLALCHEMY_ECHO.get(),
75 # Check connections before returning them.
76 "pool_pre_ping": environment.SQLALCHEMY_POOL_PRE_PING.get(),
77 "pool_size": environment.SQLALCHEMY_POOL_SIZE.get(),
78 "max_overflow": environment.SQLALCHEMY_MAX_OVERFLOW.get(),
79 "pool_recycle": environment.SQLALCHEMY_POOL_RECYCLE.get(),
80 "pool_timeout": environment.SQLALCHEMY_POOL_TIMEOUT.get(),
81 }
82 conf = get_config()
83 url = url or conf.db_url
84 if url is not None and url.startswith("sqlite"):
85 # Needed for the admin dash on sqlite.
86 kwargs["connect_args"] = {"check_same_thread": False}
87 return kwargs
88
89 def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine:
90 """Get the database engine.

Callers 2

get_engineFunction · 0.85
get_async_engineFunction · 0.85

Calls 3

get_configFunction · 0.90
startswithMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected