在python中执行存储过程
在使用python调用mysql存储过程时,我遇到了一个语法错误 存储过程的代码如下所示在python中执行存储过程,python,mysql,python-2.7,Python,Mysql,Python 2.7,在使用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_Dat
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
您需要引用ip地址,并将其作为字符串传递:
Python没有IP地址文字符号的概念
args = ('192.168.1.145', 'b8:27:eb:06:e4:4b', Temp_PI, temp)