Skip to main content

get_flask_sqlalchemy_lite_proxy_ver

FunctionSource

(
db: SQLAlchemyLiteProxy[flask_sqlalchemy.SQLAlchemy],
model_class: type[_ModelLite],
) = get_flask_sqlalchemy_lite_proxy_ver[_ModelLite](
model_class: type[_ModelLite],
app: Flask | None = None,
engine_options: Mapping[str, Any] | None = None,
session_options: Mapping[str, Any] | None = None,
)

Proxy version of get_flask_sqlalchemy_lite.

The usage and the returned value of this function is totally the same as get_flask_sqlalchemy_lite. However, the first returned value will be deliberately notated by SQLAlchemyLiteProxy, which can be used by the coders who want to use this type to remind remind them the compatibility supported by the falling back version.

Aliases

This function can be acquired by

import flask_sqlalchemy_compat as fsc


fsc.get_flask_sqlalchemy_lite_proxy_ver
fsc.auto.get_flask_sqlalchemy_lite_proxy_ver

Arguments

Requires

ArgumentTypeRequired
Description
model_classtype[_ModelLite]The base model type applied to the whole database. If flask_sqlalchemy_lite is available, this type will be directly forwarded as it is. It will not modify anything. However, if the db instance fallback to the version provided by flask_sqlalchemy, this type will be used for creating the db-specific model type.
appFlask | NoneCall init_app on this Flask application. If not specified, will not call init_app.
engine_optionsMapping[str, Any] | NoneDefault arguments passed to sqlalchemy.create_engine for each configured engine.
session_optionsMapping[str, Any] | NoneArguments to configure sessionmaker with.
  • where _ModelLite is a TypeVar of sa.orm.DeclarativeBase.

Returns

ArgumentType
Description
dbSQLAlchemyLiteProxy[flask_sqlalchemy.SQLAlchemy]

The SQLAlchemy Lite extension instance. In run time, it is the same as the returned value of get_flask_sqlalchemy_lite.

However, this returned value is always notated by SQLAlchemyLiteProxy, which provides the notations of the behaviors when flask_sqlalchemy_lite is absent.

model_classtype[_ModelLite]

If db is flask_sqlalchemy_lite.SQLAlchemy, will return model_class directly.

If db is SQLAlchemyLiteProxy[flask_sqlalchemy.SQLAlchemy], will return db.Model as the falling back option.