create_database_engine¶
- safir.database.create_database_engine(url: str, password: Optional[str], *, isolation_level: Optional[str] = None, pool_pre_ping: bool = False) sqlalchemy.ext.asyncio.engine.AsyncEngine ¶
Create a new async database engine.
- Parameters
url (
str
) – Database connection URL, not including the password.isolation_level (
str
, optional) – If specified, sets a non-default isolation level for the database engine.pool_pre_ping (
bool
, optional) – If set toTrue
, test each connection from the pool before using it for a new session. This means a database query is run each time a session is created.
- Returns
engine – Newly-created database engine. When done with the engine, the caller must call
await engine.dispose()
.- Return type
- Raises
ValueError – A password was provided but the connection URL has no username.