cliche.web.db — Database connections

Use session in view functions.

cliche.web.db.close_session(exception=None)

Close an established session.

cliche.web.db.get_database_engine()

Get a database engine.

Returns:a database engine
Return type:sqlalchemy.engine.base.Engine
cliche.web.db.get_database_engine_options()

Get a dictionary of options for SQLAlchemy engine. These options are used by get_database_engine() and passed to sqlalchemy.create_engine() function.

cliche.web.db.get_session()

Get a session. If there’s no yet, create one.

Returns:a session
Return type:Session
cliche.web.db.session = <LocalProxy unbound>

(LocalProxy of Session) The context local session. Use this.

cliche.web.db.setup_session(app)

Setup the app to be able to use session.

Parameters:app (Flask) – the Flask application to setup