get_flask_sqlalchemy_lite
FunctionSource
(
db: flask_sqlalchemy_lite.SQLAlchemy,
model_class: type[_ModelLite],
) = get_flask_sqlalchemy_lite[_ModelLite](
model_class: type[_ModelLite],
app: Flask | None = None,
engine_options: Mapping[str, Any] | None = None,
session_options: Mapping[str, Any] | None = None,
)
Get the Flask SQLAlchemy Lite DB instance in the compatible mode.
This method will attempt to get the flask_sqlalchemy_lite.SQLAlchemy
DB instance.
If the attempt fails (package is not installed), will fallback to use
flask_sqlalchemy.SQLAlchemy
to imitate the interfaces of
flask_sqlalchemy_lite.SQLAlchemy
.
Aliases
This function can be acquired by
import flask_sqlalchemy_compat as fsc
fsc.get_flask_sqlalchemy_lite
fsc.auto.get_flask_sqlalchemy_lite
Arguments
Requires
Argument | Type | Required | |
---|---|---|---|
model_class | type[_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. | |
app | Flask | None | Call init_app on this Flask application. If not specified, will not call init_app . | |
engine_options | Mapping[str, Any] | None | Default arguments passed to sqlalchemy.create_engine for each configured engine. | |
session_options | Mapping[str, Any] | None | Arguments to configure sessionmaker with. |
- where
_ModelLite
is aTypeVar
ofsa.orm.DeclarativeBase
.
Returns
Argument | Type | |
---|---|---|
db | flask_sqlalchemy_lite.SQLAlchemy | The SQLAlchemy Lite extension instance. It will be an instance of If the package is not available, will attempt to return a |
model_class | type[_ModelLite] | If If |