Retrieving all columns of a table

277 views
Skip to first unread message

Alex Schmitt

unread,
Jun 10, 2014, 7:24:26 PM6/10/14
to peewe...@googlegroups.com
Hi again, 

Was wondering if there is a way to get all the columns of a table with peewee, without calling them all individually? I'm just trying to print out the values of each column in a SELECT(), without explicitly naming each column. I guess getting all columns from a query in a dictionary would be perfect for my purposes.

Thanks a lot,
Alex

Charles Leifer

unread,
Jun 10, 2014, 9:23:35 PM6/10/14
to peewe...@googlegroups.com
http://peewee.readthedocs.org/en/latest/peewee/api.html#SelectQuery.dicts

Basically:

for row_dict in MyModel.select().dicts():
    print row_dict <-- a dictionary of field_name: value


--
You received this message because you are subscribed to the Google Groups "peewee-orm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to peewee-orm+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Schmitt

unread,
Jun 11, 2014, 10:05:06 AM6/11/14
to peewe...@googlegroups.com
Perfect, thanks a lot.
Reply all
Reply to author
Forward
0 new messages