[Python] Using OR in SQLAlchemy

Discussão em 'Python' iniciado por Stack, Agosto 4, 2025.

  1. Stack

    Stack Membro Participativo

    I've looked through the docs and I cant seem to find out how to do an OR query in SQLAlchemy. I just want to do this query.

    SELECT address FROM addressbook WHERE city='boston' AND (lastname='bulger' OR firstname='whitey')


    Should be something like

    addr = session.query(AddressBook).filter(City == "boston").filter(????)

    Continue reading...

Compartilhe esta Página