code: def get_db(directory, engine=None):
      
      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
docs: Get a database
  
      :param directory: The root data directory
      :param engine: a pre-created SQLAlchemy engine (default: in-memory SQLite)