tahrir.database module

Use sqlalchemy-helpers.

Import the functions we will use in the main code and in migrations.

class tahrir.database.TahrirDatabaseExtension(app=None)[source]

Bases: object

A Flask extension to configure the database manager according the the app’s configuration.

It cleans up database connections at the end of the requests, and creates the CLI endpoint to sync the database schema.

before_request()[source]

Prepare the database at the start of each request.

get_db()[source]

Prepare the database at the start of each request.

init_app(app)[source]

Initialize the extention on the provided Flask app

Parameters:

app (flask.Flask) – the Flask application.

teardown(exception)[source]

Close the database connection at the end of each requests.