Ejemplo n.º 1
0
def unregister_models(base=BASE):
    """Unregister Models, useful clearing out data before testing."""
    try:
        engine = session.get_engine(sqlite_fk=True)
        base.metadata.drop_all(engine)
    except Exception:
        LOG.exception(_("Database exception"))
Ejemplo n.º 2
0
def register_models(base=BASE):
    """Register Models and create properties."""
    try:
        engine = session.get_engine(sqlite_fk=True)
        base.metadata.create_all(engine)
    except sql.exc.OperationalError as e:
        LOG.info(_("Database registration exception: %s"), e)
        return False
    return True
Ejemplo n.º 3
0
def configure_db():
    """Configure database.

    Establish the database, create an engine if needed, and register
    the models.
    """
    global _DB_ENGINE
    if not _DB_ENGINE:
        _DB_ENGINE = session.get_engine(sqlite_fk=True)
        register_models()