Skip to main content

get_flask_sqlalchemy_proxy_ver

FunctionSource

db: SQLAlchemyProxy[
flask_sqlalchemy_lite.SQLAlchemy, _ModelLite
] = get_flask_sqlalchemy_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.

The usage and the returned value of this function is totally the same as get_flask_sqlalchemy. However, the first returned value will be deliberately notated by SQLAlchemyProxy, 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_proxy_ver
fsc.auto.get_flask_sqlalchemy_proxy_ver

Arguments

Requires

ArgumentTypeRequired
Description
model_classtype[_ModelLite]The base model type applied to the whole database. If flask_sqlalchemy is available, this type will be used as model_class argument for creating the db-specific base model type. However, if the db instance fallback to the version provided by flask_sqlalchemy_lite, this type will be modified inplace to imitate the behavior of flask_sqlalchemy.SQLAlchemy().Model.
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
dbSQLAlchemyProxy[flask_sqlalchemy_lite.SQLAlchemy, _ModelLite]

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

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