Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python SQLAlchemy Basics Working with SQLAlchemy Creating Our Book Database

Andy McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andy McDonald
Python Development Techdegree Graduate 13,801 Points

How to turn a query object into a dictionary?

I'm trying to use kwargs in the search function for this project. The difficulty is not necessarily that it is a query object but that im trying to create a single entry with multiple key/value pairs. At one point I was creating a dict that had an entire class object as a value to one key and since then I've tried a lot of different things, iterating through loops within loops, appending empty lists and trying to zip them together, indexing within a loop and now I've tumbled down the rabbit hole so deeply I cannot remember why I needed to use kwargs in the first place. But I'm pretty sure that knowing how to do this will at least be helpful in the future if not immediately after I remember why I wanted to use kwargs in the first place.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Lots of variations on a theme. One of these may be the form you’re looking for in this StackOverflow answer.

Post back which one you choose. Good luck!