Karthi Karthi - 4 years ago 85
MySQL Question

Inserting data into MySql table using python Petl module showing error

  • Hi I am using
    python module to perform ETL operations.

  • While I am trying to insert data into MySQL table it shows
    Parameters for query must be list or tuple
    ) error.

Here is the sample code of what I tried,

from petl import todb

import mysql.connector

table = [['foo', 'bar'], ['a', 1], ['b', 2], ['c', 2]]
connection = mysql.connector.connect(host='',database='test',user='root',password='123')
connection.cursor().execute('SET SQL_MODE=ANSI_QUOTES')
todb(table, connection, 'petlTest')

except Exception, exception:
print exception

Note : Table petlTest was created already with columns foo and bar.

Answer Source

I fixed the issue by changing the mysql.connector to mysql-python module.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download