如何通过 pd.read_sql 传递多个参数,一个是单数,另一个是列表格式?

How do I pass multiple parameters via pd.read_sql, one singular and another in list format?

我的原始数据为:

id = 2345  
id_num = 3,6,343,32  

我需要通过 cx_Oracle 连接在 ORACLE SQL 查询中将以上两个作为参数传递为:

query = “””  
        select * from mytable where pid = 2345 and id_num in (3,6,343,32)  
        “””  

我正在创建字典:

sparm = {}  
sparm['pid'] = id  
sparm['idnum'] = id_num  

并尝试将其用作:

query = “””  
        select * from mytable where pid = :pid and id_num in :idnum  
        “””  

df = pd.read_sql(query, con=conct, params=sparm)  

没有成功。
:pid 有效,但 :idnum 无效。任何建议将不胜感激。

我的原始数据为:

id = 2345  
id_num = 3,6,343,32  

我需要通过 cx_Oracle 连接在 ORACLE SQL 查询中将以上两个作为参数传递为:

query = “””  
        select * from mytable where pid = 2345 and id_num in (3,6,343,32)  
        “””  

我正在创建字典:

sparm = {}  
sparm['pid'] = id 

并为 where 子句创建一个元组:

where=tuple(list(id_num.split(","))) 

并尝试将其用作:

query = “””  
        select * from mytable where pid = :pid and id_num in {}  
        “””.format(where)

df = pd.read_sql(query, con=conct, params=sparm)  

成功。 :pid 与字典输入一起使用,而 :idnum 与元组输入一起使用。