panda.run_sql_query在哪里.在 .结构



我有一个SQL查询,其结构为b类。我正在尝试使用run_sql_query通过熊猫来运行它,以使数据框架恢复。但是,似乎没有数据结构可用于熊猫查询。我应该有什么才能使它起作用?

sql:

Select * from Table where a in (:input)

python:

conn = cx-oracle.connect(....)
df = pd.run_sql_query(sql,conn, params= {'input':('A','B')})

错误消息:

cx_Oracle.NotSupportedError: Python value of type tuple not supported.

我尝试了numpy数组和列表,但似乎没有用。这里应该使用哪些数据结构?

尝试以下:

myinput = ('a','b','c')
myinput = str(myinput)
#Now your query will end up like
# select * from tablename where value in ('a','b','c')
df = pd.run_sql_query(sql,conn, params= {'input':myinput})

最新更新