Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

what I'm wrong (2 replies)

$
0
0
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?

Viewing all articles
Browse latest Browse all 384

Trending Articles