MySQL Asterisk AGI-ValueError:无法处理参数

问题描述 投票:0回答:1

所以我一直在对此问题进行故障排除一分钟,很奇怪的是,它似乎可以在独立的Python脚本中正常运行,但是当移至星号AGI时,出现以下错误:

cursor.execute(query, (res))
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/cursor_cext.py", line 248, in execute
prepared = self._cnx.prepare_for_mysql(params)
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection_cext.py", line 615, in prepare_for_mysql
raise ValueError("Could not process parameters")

下面是引发该错误的正在运行的数据。

#!/usr/bin/env python
import sys
from asterisk.agi import *
from os import system
import subprocess
import time
import mysql.connector
import md5

agi = AGI()
agi.verbose("python agi started")
callerId = agi.env['agi_callerid']
agi.verbose("call from %s" % callerId)
res=agi.get_variable("res")
agi.verbose("want %s br" %res)

cnx = mysql.connector.connect(user='user',password='sanitized',host='127.0.0.1',database='rental')

cursor = cnx.cursor(buffered=True)

query = ("select active,address,rent,deposit,phone,pets_allow,smoker_allow,section_8,garage,attached_garage,fenced_yard,carport,shed,patio,deck,basement,garden_area,off_street,on_street,walkin_shower,double_lavs,back_porch,front_porch,cha,ac,fireplace,central_heat,stove,dish_washer,microwave,refrigerator,washer,dryer,washer_hu,dryer_hu,garbage_dispsal,water,trash_service,gas,electric,barn,wall_furnace from activelisting where active=1 and number_br=3")
query = ("select active,address,rent,deposit,phone,calldialog,id from activelisting where active=1 and number_br=3 order by id")

cursor.execute(query, (res))

cursor.close()

cnx.close()

注意:number_br = 3,从技术上讲应该为number_br =%s,但是为了进行故障排除,我将其替换为静态变量。整个脚本可以在较旧版本的CentOS上运行,而我正试图使它们全部在Debian Server上运行。

python mysql asterisk agi
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.