Ejemplo n.º 1
0
def init(engine, base=Base, should_create=False, should_drop=False):
    """Initialise the database tables managed by `h.db`."""
    if should_drop:
        base.metadata.reflect(engine)
        base.metadata.drop_all(engine)
    if should_create:
        base.metadata.create_all(engine)
    api_db.init(engine, should_create=should_create, should_drop=should_drop)
Ejemplo n.º 2
0
def init(engine, base=Base, should_create=False, should_drop=False):
    """Initialise the database tables managed by `h.db`."""
    if should_drop:
        base.metadata.reflect(engine)
        base.metadata.drop_all(engine)
    if should_create:
        base.metadata.create_all(engine)
    api_db.init(engine, should_create=should_create, should_drop=should_drop)
Ejemplo n.º 3
0
def init(engine, base=Base, should_create=False, should_drop=False):
    """Initialise the database tables managed by `h.db`."""
    if should_drop:
        base.metadata.reflect(engine)
        base.metadata.drop_all(engine)
    if should_create:
        # In order to be able to generate UUIDs, we load the uuid-ossp
        # extension.
        engine.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";')
        base.metadata.create_all(engine)
    api_db.init(engine, should_create=should_create, should_drop=should_drop)
Ejemplo n.º 4
0
def db_engine():
    """Set up the database connection and create tables."""
    engine = sqlalchemy.create_engine(TEST_DATABASE_URL)
    db.init(engine, should_create=True, should_drop=True)
    return engine
Ejemplo n.º 5
0
def db_engine():
    """Set up the database connection and create tables."""
    engine = sqlalchemy.create_engine(TEST_DATABASE_URL)
    db.init(engine, should_create=True, should_drop=True)
    return engine