from utils import Base, metadata_rc, session_rc from sqlalchemy import Table class Documents(Base): __table__ = Table("core_document", metadata_rc) def get_documents(): documents = session_rc.query(Documents).all() for document in documents: yield document if __name__ == "__main__": get_documents()