example.db_schema

db_schema.py

Database schema update and seed functions - populate a new db with minimum data

created 31-mar-2019 by richb@instantlinux.net

Functions

alembic_migrate(models, version, script_location)

run schema migrations

get_session([scopefunc, scoped, db_url, engine])

open a db session scoped to flask context or celery thread

update(db_engine, models[, migrate, …])

Run alembic migrations for updating schema

Classes

Account(**kwargs)

AlembicVersion(**kwargs)

Category(**kwargs)

Contact(**kwargs)

Location(**kwargs)

Person(**kwargs)

Settings(**kwargs)

TZname(**kwargs)

Exceptions

OperationalError(statement, params, orig[, …])

Wraps a DB-API OperationalError.

ProgrammingError(statement, params, orig[, …])

Wraps a DB-API ProgrammingError.

example.db_schema.update(db_engine, models, migrate=False, schema_maxtime=0)

Run alembic migrations for updating schema

Must be called with mutex for duration of update to prevent race conditions; begin_transaction() does not ensure mutual exclusion.

params:

models - models to generate or update migrate - perform migrations only if True schema_maxtime - maximum seconds to wait for mutex