os_name = platform.system()
id = request.get_json()['id']
#id = request.args.get('id')
print("id in getBeiJingTu ,="+str(id))
sql1 = "SELECT beiJingTuMing FROM user_info where id=%s;"
cur_new = db.cursor()
if (os_name.lower() == "Windows".lower()):
print("in getBeiJingTu on windows")
params1 = (id)
#cur = db.cursor()
print(cur_new.mogrify(sql1, params1))
#cur.execute(sql1,params1,)
cur_new.execute(sql1, params1)
beiJingTuMing_new = cur_new.fetchall()
elif (os_name.lower() == "Linux".lower()):
print("in getBeiJingTu on linux")
params1 = (id,)
#cur = db.cursor()
print(cur_new.mogrify(sql1, params1))
cur_new.execute(sql1,params1,)
beiJingTuMing_new = cur_new.fetchall()
else:
print("操作系统不匹配,哪里有问题?in getBeiJingTu")
# 获取查询结果
#beiJingTuMing_new = cur.fetchall()
if(beiJingTuMing_new and len(beiJingTuMing_new[0]) > 0):
beiJingTuMing_new_1 = beiJingTuMing_new[0][0]
print("beiJingTuMing_new_1=",beiJingTuMing_new_1)
cur_new.close()
return beiJingTuMing_new_1
else:
print("beiJingTuMing_new=",beiJingTuMing_new)
cur_new.close()
return str(-109)
有id,比如输出:
id in getBeiJingTu ,=50
in getBeiJingTu on linux
SELECT beiJingTuMing FROM user_info where id=50;
beiJingTuMing_new= ()
但是用sql语言执行:SELECT beiJingTuMing FROM user_info where id=50;
结果是一个字符串。有时候,又能拿到字符串。奇怪。
总是报:pymysql.err.InterfaceError: (0, ''),百度也无果。谁知道是怎么回事吗?谢谢
--
修改:feng321 FROM 39.146.76.*
FROM 39.146.76.*