使用python调用mysql的存储过程时,我收到语法错误。
存储过程的代码如下,
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])
错误如下;
File "procedure.py", line 53
args= (192.168.1.145, b8:27:eb:06:e4:4b, Temp_PI, temp)
^
SyntaxError: invalid syntax
答案 0 :(得分:2)
您需要引用 IP地址,并将其作为字符串传递:
args = ('192.168.1.145', 'b8:27:eb:06:e4:4b', Temp_PI, temp)
Python没有IP地址文字符号的概念。