Reputation: 257
While calling the stored procedure of mysql using python, I am getting a syntax error.
The code for the stored procedure is as follows,
while True:
try:
date = time.strftime("%d/%m/%Y")
temp,humidity,light = main.reading()
args= (192.168.1.145, b8:27:eb:06:e4:4b, Temp_PI, temp)
cursor.callproc('SPR_IU_Sensor_Data',args)
conn.commit()
time.sleep(interval2)
except:
MySQLdb.Error, e:
conn.rollback()
print "Transaction aborted: %d: %s" % (e.args[0], e.args[1])
The error is as follows;
File "procedure.py", line 53
args= (192.168.1.145, b8:27:eb:06:e4:4b, Temp_PI, temp)
^
SyntaxError: invalid syntax
Upvotes: 1
Views: 786
Reputation: 1121584
You need to quote the ip addresses, pass them in as strings:
args = ('192.168.1.145', 'b8:27:eb:06:e4:4b', Temp_PI, temp)
Python has no notion of an IP address literal notation.
Upvotes: 2