[Python] SQLAlchemy get list of ids from a query

Discussão em 'Python' iniciado por Stack, Junho 29, 2025.

  1. Stack

    Stack Membro Participativo

    How do I get a list of ids instead of a list of SQLAlchemy objects? Currently I'm doing this:

    [x.id for x in random_query.all()]


    Is there a better way of doing this, preferably by only using SQLAlchemy statements.

    Continue reading...

Compartilhe esta Página