create_database_engine

safir.database.create_database_engine(url: str, password: Optional[str], *, isolation_level: Optional[str] = None) AsyncEngine

Create a new async database engine.

Parameters:
  • url (str) – Database connection URL, not including the password.

  • password (str or None) – Database connection password.

  • isolation_level (str, optional) – If specified, sets a non-default isolation level for the database engine.

Returns:

engine – Newly-created database engine. When done with the engine, the caller must call await engine.dispose().

Return type:

sqlalchemy.ext.asyncio.AsyncEngine

Raises:

ValueError – A password was provided but the connection URL has no username.