MySQL Forums
Forum List  »  Connector/Python

what I'm wrong
Posted by: Terence Chan
Date: December 08, 2014 06:57AM

try:
conn = mysql.connector.connect(
host=investcfg.host,
user=investcfg.user,
password=investcfg.pw,
database=investcfg.db,
charset=investcfg.charset)

except mysql.connector.Error as err:
print "Error %d: %s" % (err.args[0], err.args[1])
sys.exit(1)

cursor = conn.cursor()
wdate = datetime.date(2014,12,7)

try:
cursor.execute("Delete from Prices_tmp where `Code` not in " +
"(select Code from Stocks b)")

cursor.execute("Delete from `Prices_tmp` where `Code` in " +
"(select b.`Code` from `Prices` b where b.`Code` = %s)", (wdate))

except mysql.connector.Error as err:
print "Error %d: %s" % (err.args[0], err.args[1])
cursor.close()
conn.close()
sys.exit(1)

cursor.close()
conn.close()

I get the error for the about script.

Error 1064: 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 '%s)' at line 1

may I know how to pass date parameter to the script? what is wrong is it? I user lubuntu 14.04. Python 2.7.8?

Options: ReplyQuote


Subject
Written By
Posted
what I'm wrong
December 08, 2014 06:57AM
December 10, 2014 10:05AM
December 13, 2014 08:09AM


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.