I'm just attempting to add some data in bulk.
I firstly connect then iterate through dictionary items, creating each query to update the zip_ids table, which is mysql based. Below is how I am doing this:
connection = _mysql.connect(host="xxx",user = "user", passwd="123", db="mine")
for id, zip in id_zip.items():
query += """UPDATE zip_ids SET zip = %s id = %s;"""% (zip,id)
print query
try:
cur = connection.cursor()
connection.execute(query, multi=True)
connection.commit()
cur.close()
connection.close()
connection.disconnect()
except _mysql.connector.Error as err:
print 'issue in Execution of adding zip', str(e)
Issue is that I keep getting an exception thrown:
Exception 'module' object has no attribute 'connector'
How can I resolve this exception? What is its cause? Is the code for adding data in bulk correct?
_msqlhere? Where is that imported from? Presumably theexcept _mysql.connector.Error as err:line is throwing the exception, so you need to tell us more about where that module comes from.import mysql.connector?