Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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在SQL查询中使用一系列变量_Python_Python 3.x - Fatal编程技术网

使用Python在SQL查询中使用一系列变量

使用Python在SQL查询中使用一系列变量,python,python-3.x,Python,Python 3.x,我有一系列ID: ID:['A10','B10','C44'.......] 我正在运行SQL查询以从表中提取信息。目前,我正在做的就是: for s in ID: sqlquery="Select Name, Age, ID from table where ID=%s" result=cursor.execute(sqlquery,(s,)) 但是这需要很多时间,因为我在这个系列中存储了大约100个ID。我是否可以使用SQL的'in'子句?大概是这样的: sqlquery="S

我有一系列ID:

ID:['A10','B10','C44'.......]
我正在运行SQL查询以从表中提取信息。目前,我正在做的就是:

for s in ID:
  sqlquery="Select Name, Age, ID from table where ID=%s"
  result=cursor.execute(sqlquery,(s,))
但是这需要很多时间,因为我在这个系列中存储了大约100个ID。我是否可以使用SQL的'in'子句?大概是这样的:

 sqlquery="Select Name,Age, ID from table where ID in...."
如何在上述查询中使用序列ID?如何使用游标执行它