create_database_engine#

safir.database.create_database_engine(url, password, *, connect_args=None, isolation_level=None, max_overflow=None, pool_size=None, pool_timeout=None)#

Create a new async database engine.

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

  • password (Union[str, SecretStr, None]) – Database connection password.

  • connect_args (Optional[dict[str, Any]], default: None) – Additional connection arguments to pass directly to the underlying database driver.

  • isolation_level (Optional[str], default: None) – If specified, sets a non-default isolation level for the database engine.

  • max_overflow (Optional[int], default: None) – Maximum number of connections over the pool size for surge traffic.

  • pool_size (Optional[int], default: None) – Connection pool size.

  • pool_timeout (Optional[float], default: None) – How long to wait for a connection from the connection pool before giving up.

Returns:

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.