to cursor.execute( ).
I have tried, with success, to do like every single example (that I
have found on the www) on the subject shows, to use a insert statement
on the form:
statement = INSERT INTO table (colA,colB,colC ) values (%s,%s,%s)
and pass in a list containing tuples
list = [('bla','bla','b la'),('bla','bl a','bla'),('bla ','bla','bla')]
on the form
cursor.executem any(statement,l ist)
This works fine for all strings, but I have never been able to insert a
single integer or a float using this method. I get an error message
reporting that float (or an int) is required.
Statement is then of course changed to something like
statement = INSERT INTO table (colA,colB,colC ) values (%s,%i,%f)
list = [('bla',1,0.65), ('bla',3,3.7),( 'bla',3,0.9)]
Havee anybody experienced similar problems?
Am I doing something wrong?
Any feedback is greatly appreciated.
Here is som real output from the interpreter:
statement = 'insert into testtable3 (url,probabilit y) values (%s,%f)'
l [('url1', 0.9899999999999 9999), ('url2', 0.8900000000000 0001)] cursor.executem any(statement,l )
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\Li b\site-packages\MySQLd b\cursors.py", line 181, in
execu
any
self.errorhandl er(self, TypeError, msg)
File "C:\Python24\Li b\site-packages\MySQLd b\connections.p y", line 33,
in de
lterrorhandler
raise errorclass, errorvalue
TypeError: float argument required