Skip navigation links

MySQL Forums :: Connector/Python :: Question with python connector 1064 (42000): You have an error in your SQL syntax;


Advanced Search

Question with python connector 1064 (42000): You have an error in your SQL syntax;
Posted by: John Doe ()
Date: March 25, 2013 07:34AM

I have a small python program to generate following sql

update AggGMDB set GMDBDIFF1 = ifnull(GMDB200603,0)- ifnull(GMDB200512,0)

but it gives the following error

mysql.connector.errors.ProgrammingError: 1064 (42000): 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 ''GMDBDIFF1' = ifnull('GMDB200603',0)- ifnull('GMDB200512',0)' at line 1

What am I doing wrong

here is a fragment of the python program

count=0
for column1,column2 in columns:
count +=1
print count
NewColumn = "GMDBDIFF" + str(count)
query = "alter table AggGMDB add "+ NewColumn + " decimal(30,2)"
cursor.execute(query)
query ="update AggGMDB set %s = ifnull(%s,0)- ifnull(%s,0)"
print query
print "Computing the difference between %s and %s" %(column1,column2)
print query %(NewColumn,column1,column2)
cursor.execute(query,(NewColumn,column1,column2))
cnx.commit()
cursor.close()
cnx.close()

Options: ReplyQuote


Subject Written By Posted
Question with python connector 1064 (42000): You have an error in your SQL syntax; John Doe 03/25/2013 07:34AM
Re: Question with python connector 1064 (42000): You have an error in your SQL syntax; Geert Vanderkelen 04/24/2013 05:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.