Is it possible to do SELECT * in sqlalchemy?
Edit: Specifically, SELECT * WHERE foo=1
Is it possible to do SELECT * in sqlalchemy?
Edit: Specifically, SELECT * WHERE foo=1
If you don't list any columns, you get all of them.
query = users.select()
query = query.where(users.c.name=='jack')
result = conn.execute(query)
for row in result:
print row
Should work.
Is no one feeling the ORM love of SQLALchemy today? The presented answers correctly describe the lower level interface that SQLAlchemy provides. Just for completeness this is the more-likely (for me) real-world situation where you have a session instance and a User class that is orm mapped to the users table.
for user in session.query(User).filter_by(name='jack'):
print user
# ...
And this does an explicit select on all columns.
Where Bar is the class mapped to your table and session is your sa session:
bars = session.query(Bar).filter(Bar.foo == 1)