Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python MySQL语句中缺少操作数_Python_Mysql - Fatal编程技术网

Python MySQL语句中缺少操作数

Python MySQL语句中缺少操作数,python,mysql,Python,Mysql,我从MySQL模块中得到一个参数错误,查找4个操作数。我只是不知道它在找哪个操作数。它适用于某些案例类型,而不适用于其他案例类型。错误行号(底部修剪,参考MySQL库): 这行代码.execute(…)将失败: getPhysiciansql_cmd = "SELECT physicianName FROM physicianNamesSpecialties WHERE (specialty, specialty2, specialty3, specialty4) ='{}'".format(

我从MySQL模块中得到一个参数错误,查找4个操作数。我只是不知道它在找哪个操作数。它适用于某些案例类型,而不适用于其他案例类型。错误行号(底部修剪,参考MySQL库):

这行代码
.execute(…)
将失败:

getPhysiciansql_cmd = 
"SELECT physicianName FROM physicianNamesSpecialties WHERE (specialty, specialty2, specialty3, specialty4) ='{}'".format(r)
c.execute(getPhysiciansql_cmd)
我的Var
r
保存以下数据:

print("This is a", r, "service case. It is a", d,"type case.")

This is a THORACIC service case. It is a TRANSBRONCHIAL WANG NEEDLE ASPIRATION type case.
getPhysiciansql_cmd = SELECT physicianName FROM 

physicianNamesSpecialties WHERE (specialty, specialty2, specialty3, specialty4) ='THORACIC'
我的Var
getPhysiciansql\u cmd
保存以下数据:

print("This is a", r, "service case. It is a", d,"type case.")

This is a THORACIC service case. It is a TRANSBRONCHIAL WANG NEEDLE ASPIRATION type case.
getPhysiciansql_cmd = SELECT physicianName FROM 

physicianNamesSpecialties WHERE (specialty, specialty2, specialty3, specialty4) ='THORACIC'

我想这只是我如何使用WHERE子句的问题。我在某个地方看到,有多个字段的WHERE是写的,在字段周围使用paren。我已经尝试过将其减少到最低限度,并在WHERE子句中使用OR运算符,我已经成功地收到了正确的响应

import mysql.connector as mariaDB

conn = mariaDB.connect(host='xxxxx', user='xxxx',password='xxxxx',db='lookupDB')
conn2 = mariaDB.connect(host='xxxxx', user='xxxx',password='xxxxxx',db='workQueue')
c = conn.cursor()
c2 = conn2.cursor()

inputSpecialty = input("specialty? ")
r = inputSpecialty


c.execute("SELECT physicianName FROM physicianNamesSpecialties WHERE specialty = %s OR specialty2 = %s OR specialty3 = %s OR specialty4 = %s", (r,r,r,r))

physResult = c.fetchall()

cleanedUpPhysResult = physResult
print(cleanedUpPhysResult)
输出:

specialty? THORACIC
[('Song',), ('Han',), ('He',), ('Goldfischer',)]

您需要告诉我们问题所在的确切线路。你是最好的人选,不是我们。谢谢你指出这一点。回溯(最后一次调用):parse()中第158行的文件“/Users/christoph/PycharmProjects/physicianWorkQueueProject/physicianWorkQueueProject.py”,parse c.execute(getPhysiciansql\u cmd)中第138行的“/Users/christoph/PycharmProjects/physicianWorkQueueProject/physicianWorkQueueProject.py”Rest在MySQL库中跟进。什么是
WHERE(s,s2,s3,s4)='…'
应该完成的?你的意思是像s='''.'或s1='''.'或s2='.''.'..''这样的东西吗?所以我们有医生根据不同的日子或星期提供不同的服务。今天,吉姆·鲍勃在做头部和颈部检查,比利在做妇科检查。s是该人员的主要服务,但s2、s3、s4是该人员可以使用的备用服务。好的。让我再试一次。在英语中,我会说,“从表(PhysicianNamesSpecialists)中选择医生姓名(physicianName),其中R(专家与多面手的查找结果)匹配这些字段中的任何专业(专业、专业2、专业3、专业4)。”