db = MySQLdb.connect(host="xxx.xx.xx.x",
user="xxx",
passwd="xxx",
db="xxxx")
for loop on json data:
cursor = db.cursor()
cursor.execute('Insert Query')
db.commit()
db.close()
Would it be possible for me to improve this query? I'm considering doing multiple cursor.execute before db.commit()
I'm unsure how db.commit() works and the importance of it.
I'm basically looping a json data and inserting it with a loop. I cannot avoid having multiple inserts.
INSERT INTO tab_name(col_list) VALUES (...),(...),(...),(...). Insert multiple values at once.Insert Querya string? because you can always create a string the way you want. and send the execute every 10 values or something.