PyMySQL return a single dictionary - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: PyMySQL return a single dictionary (/thread-24577.html) |
PyMySQL return a single dictionary - Valon1981 - Feb-20-2020 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? RE: PyMySQL return a single dictionary - buran - Feb-20-2020 pass what you get (list/generator of tuples) to dict() function
RE: PyMySQL return a single dictionary - Valon1981 - Feb-20-2020 Thank you. |