Reputation: 1961
I want to insert dictionary data into mysql each key in its own field. I tried following code. But its wrong. Can any one help? I really appreciate. thanks so much :-)
d = {"spam": "1", etc,etc,"egg": "2"}
cols = d.keys()
vals = d.values()
stmt = "INSERT INTO table (%s) VALUES(%s)" % (
",".join(cols), ",".join(len(vals))
Upvotes: 1
Views: 1028
Reputation: 8145
Why do you call len(vals)
? Your code should work by simply removing that.
Upvotes: 2