Get a database

    :param directory: The root data directory
    :param engine: a pre-created SQLAlchemy engine (default: in-memory SQLite)

def get_db(directory, engine=None):
    """Get a database

    :param directory: The root data directory
    :param engine: a pre-created SQLAlchemy engine (default: in-memory SQLite)
    """
    if engine is None:
        engine = create_engine('sqlite://')
    tables.metadata.create_all(engine)
    Session = sessionmaker(bind=engine)
    db = Session()
    if directory is not None:
        load_from_directory(db, directory)
    return db