【问题标题】:Executing stored procedure in python在python中执行存储过程
【发布时间】:2015-02-01 11:22:15
【问题描述】:

在使用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

【问题讨论】:

    标签: python mysql python-2.7


    【解决方案1】:

    您需要引用 IP 地址,将它们作为字符串 传递:

    args = ('192.168.1.145', 'b8:27:eb:06:e4:4b', Temp_PI, temp)
    

    Python 没有 IP 地址文字符号的概念。

    【讨论】:

      猜你喜欢
      • 2010-09-15
      • 2020-01-14
      • 1970-01-01
      • 1970-01-01
      • 2019-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多