make sqlite to dict using python code example
Example: python sqlite dict
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
conn = sqlite3.connect("data.db")
conn.row_factory = dict_factory
db = conn.cursor()
print(db.execute("SELECT * FROM table"))
>>> [{'col1': 'val1', 'col2': 'val2'}, {'col1': 'val3', 'col2': 'val4'}]