My memory is failing me. I seem to recall that there was a succinct way to
get a 1.4/2.0 ORM query to return individual columns instead of ORM
objects. That is, to tell this
print(session.execute(select(User)).fetchall())
# [(<__main__.User object at 0x00000090175EC700>,)]
to return the equivalent of this
print(session.execute(select(User.id, User.name)).fetchall())
# [(1, 'Gord')]
without explicitly naming each attribute (column). A modifier like
`.as_columns()` or something like that …?
Interestingly, if I try to use `*` I only get the first (or maybe the PK)
column
print(session.execute(select(text("*")).select_from(User)).fetchall())
# [(1,)]
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/3d1d98e8-a7ac-4748-8cd3-56c32f275644n%40googlegroups.com.