Python Forum

Full Version: PyMySQL return a single dictionary
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm using pymysql to get all the contents of a table with two columns - user_id and user_name (user_id is the primary key).

is there a way to return a single dictionary with user_id's as keys and user_names as values?
pass what you get (list/generator of tuples) to dict() function
Thank you.