Im trying to save bunch of tuples in DB
cursor = cnx.cursor()
query = """INSERT INTO `TableA`
(`clientid`,
`createddatetime`,
`siteid`,...)
VALUES(?,?,?,...)"""
cursor.executemany(query, listTosave)
My listTosave contains list of tuples like;
[('AS0001', '1170', 1, '1', 'Unknown', 442, 1, datetime.datetime(2018, 5, 28, 23, 0), datetime.datetime(2018, 3, 15, 11, 15), datetime.datetime(2018, 3, 15, 10, 56), datetime.datetime(2018, 5, 28, 23, 18, 26), datetime.datetime(2018, 5, 28, 23, 59, 22), Decimal('15177.3184'), Decimal('15185.7562'), Decimal('8.4378'), Decimal('1313.0547'), Decimal('1313.6179'), Decimal('0.5632'), Decimal('0.0000'), Decimal('0.0000'), Decimal('0.0000'), Decimal('0.0000'), Decimal('0.0000'), Decimal('0.0000'), Decimal('24.6518'), Decimal('24.6518'), 15101.7062, 0.0, 0.0, 0.0, 24.6563), (........... )]
When I try to save I get;
File "/tmp/pymodules/pymysql/cursors.py", line 194, in executemany
File "/tmp/pymodules/pymysql/cursors.py", line 194, in <genexpr>
File "/tmp/pymodules/pymysql/cursors.py", line 163, in execute
File "/tmp/pymodules/pymysql/cursors.py", line 142, in mogrify
TypeError: not all arguments converted during string formatting
Why do I get this error?
Edit : I converted datetime objects/decimal objects also to string. My new list is like;
[('AS0001', '1170', '1', '1', 'Unknown', '442', '1', '2018-05-28 23:00:00', '2018-03-15 11:15:00', '2018-03-15 10:56:00', '2018-05-28 23:18:26', '2018-05-28 23:59:22', '15177.3184', '15185.7562', '8.4378', '1313.0547', '1313.6179', '0.5632', '0.0000', '0.0000', '0.0000', '0.0000', '0.0000', '0.0000', '24.6518', '24.6518', '15101.7062', '0.0', '0.0', '0.0', '24.6563'), (.....)]
But still I get same error