1

I am trying to insert data into a mySql database using a python script. When I run the python script I receive the following error:

Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dataBaseName' exited abnormally with signal 11: Segmentation fault: 11
')' at line 2

Here is the insert statement in my code:

with con:
    cur = con.cursor()
    for mID,l,tm,s,f,p,m in zip(messageID,level,time,sender,facility,pid,message):
        cur.execute("INSERT INTO LogData(ASLMessageID,Level,Time,Sender,Facility,PID,Message) VALUES('"+ mID + "','" + l + "'," + tm + ",'" + s + "','" + f +"','" + p +"','" + m + "')")

There are 7 lists one for each column in the table and I am trying to simply fill the table.This worked for 4 other tables but for some reason this one is giving this error.Thanks for any help you can give.

Here is my connection code:

    import MySQLdb as mdb
    import sys

    con = None
    try:

      con = mdb.connect('localhost', 'root', 'password', 'dataBaseName')
4

0 回答 0