db#
Attributes#
Custom configuration for SQLAlchemy |
|
An SQLAlchemy engine used to instantiate connections |
|
A Flask-SQLAlchemy object, needed for per-request connection handling |
Functions#
|
Returns the config in |
|
Returns the DB config as a single URI string |
|
Returns the DB config as a list of mysql client CLI parameters |
Returns an SQLAlchemy Connection object. |
|
|
Returns an SQLAlchemy Session object. |
Returns a database connection that is initialized in transaction mode |
Package Contents#
- db.get_config(env: str = None) dict[source]#
Returns the config in
db/config.tomlfor the current environment
- db.get_cli_connection_params() list[str][source]#
Returns the DB config as a list of mysql client CLI parameters
- db.get_connection()[source]#
Returns an SQLAlchemy Connection object.
Usually, the code will use an SQLAlchemy Session, but this function is used for direct queries that do not need the ORM setup. For the most part, this is migrations.
- db.get_session(conn=None)[source]#
Returns an SQLAlchemy Session object.
This may be used to wrap an existing connection into an ORM-aware session. If the given connection is actually a Session, it simply returns it.
Part of the reason this is happening is because of legacy reasons, but it’s also used to wrap a transaction connection from
get_transaction. Ideally, this shouldn’t be necessary, but getting transactions to work for sessions has been a pain and this was the combination of entities that got us there. It may be simplified in the future.