I want to do the following SQL statement:
INSERT INTO myTable (name, year) VALUES ("David", 2016)
Is there a simple way to do the above INSERT
using a dictionary:
d = {
"name": "David",
"year": 2016
}
Perhaps something like:
cursor.execute('INSERT INTO myTable (%s) VALUES (%s)', (d.keys(), d.values())
Or even:
cursor.execute('INSERT INTO myTable %s', (d.items(),))