hello
I am inserting records into a MYSQL table via a loop

Records are being inserted, but every now and then the program bombs out with the below message

There is nothing wrong with the query line though (If i restart the job, this record will be inserted without issue)

Help is much appreciated

Unable to execute query INSERT INTO `shmosis`.`shmosis` (companyname, Addressline1, Addressline2, Addressline3, Addressline4, Postcode,BicName, ContactName, ContactTelephone, lastcontacted,established,txtDesc,Email,MobileNumber,StaffNumber,Title,Forename,Surname,FaxNumber,BicSubCodeNew,Ref ) VALUES ("Robertson Northern","Buckie High School","West Cathcart Street","","Aberdeen","AB56 1QB","Trade and Building > Sites > Buildings","Mr Skene","01542839198","2009-11-11 16:46:37","Under","construction site","d.skene@robertson.co.uk","","20-49","Mr","","Skene","","10401","40090923181621407045")
Traceback (most recent call last):
File "./ste.py", line 263, in <module>
db.queryNoReturn(dbquery)
File "./ste.py", line 74, in queryNoReturn
self.disconnect()
File "./ste.py", line 64, in disconnect
self._conn.close()
_mysql_exceptions.ProgrammingError: closing a closed connection

It works fine, this is what i am saying (Is this a timeout issue)?

Thanks

File "./ste.py", line 64, in disconnect
self._conn.close()
_mysql_exceptions.ProgrammingError: closing a closed connection

Why are you closing a connection (twice) for a db that you are adding records to. How about some code. Also, you do not have to commit after every add, so wait until after you have added x records, which may also be part of the problem. Also, it could be a log file that is full. The workaround is to add some number of records, then close the db, open it again, add some more records, etc. but that is only if all else fails. Please post any solutions you find as this is the kind of thing that can waste hours trying to track down.

This article has been dead for over six months. Start a new discussion instead.