def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine:
    """Get the database engine.

    Args:
        url: the DB url to use.

    Returns:
        The database engine.

    Raises:
        ValueError: If the database url is None.
    """
    conf = get_config()
    url = url or conf.db_url
    if url is None:
        msg = "No database url configured"
        raise ValueError(msg)

    global _ENGINE
    if url in _ENGINE:
        return _ENGINE[url]

    if not environment.ALEMBIC_CONFIG.get().exists():
        console.warn(
            "Database is not initialized, run [bold]reflex db init[/bold] first."
        )
    _ENGINE[url] = sqlmodel.create_engine(
        url,
        **get_engine_args(url),
    )
    return _ENGINE[url]
Get the database engine.

    Args:
        url: the DB url to use.

    Returns:
        The database engine.

    Raises:
        ValueError: If the database url is None.
    
reflex/model.py