Reputation: 21
Made a Sample script in Python to dedupe records from Mysql and was Trying to insert around 15k records in data into Mysql database :
The query I am using is :
c2.execute("INSERT INTO dedable_city %s VALUES %s" % (values, lst))
Where 'values' in the column names and 'lst' is the records.
This is the error on the console:
File "dedupe_main3.py", line 208, in <module>
c2.execute("INSERT INTO deduped_new_table_city %s VALUES %s" % (values, lst))
/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.OperationalError: (1054, "Unknown column 'None' in 'field list'")
This is the query when i print it:
INSERT INTO deduped_new_table_city (col,col,col,col,col,col,col,col,col,col,col)
VALUES (val, 'val', 'val', 'val', 'val', val , val , 'val', 'val', val, 'val')
What am I missing here?Tried searching online but to no avail.
Edit 1 : 'Values' contain
(cluster_id,uniqueid,id,name,hcode,suame,adress,hphone,zipcode,latitude,longitude,rating,city,country)
Upvotes: 2
Views: 480
Reputation: 5396
You have an error, you need brackets, it should be:
c2.execute("INSERT INTO dedable_city (%s) VALUES (%s)" % (values, lst))
or you need your values variable to be something like this:
values="(column1,column2,column3)"
and the same applies to your lst values
EDIT You can also try it this way:
c2.execute("INSERT INTO deduped_new_table_city %s VALUES %s",values, lst)
Upvotes: 1