[Python] How can I query a (PostgreSQL) View with SQLAlchemy

Discussão em 'Python' iniciado por Stack, Outubro 6, 2024.

  1. Stack

    Stack Membro Participativo

    Usually I connect/query like this

    class MyTable(Base):
    __tablename__ = 'mytable'
    __table_args__ = {'schema': 'tables'}

    id = Column(Integer, primary_key=True)
    salutation = Column(VARCHAR(1))

    def __init__(self, salutation):
    self.salutation = salutation

    def load():
    """"""
    Session = sessionmaker(bind=engine)
    session = Session()
    for i in session.query(MyTable).order_by(MyTable.id):
    entries.append(i.__dict__)
    session.close()


    But How I query an (PostgreSQL) DB View, without any keys?

    Continue reading...

Compartilhe esta Página