Pythonでcx_Oracleを使用して準備されたOracle文でIN句を使用したいと思います。PythonでOracle Prepared StatementのIN句cx_Oracle
など。クエリ - これは動作しません
import cx_Oracle
ids = [101, 102, 103]
ALL_IDS = "('{0}')".format("','".join(map(str, ids)))
conn = cx_Oracle.connect('username', 'pass', 'schema')
cursor = conn.cursor()
results = cursor.execute('select name from employee where id in :id_list', id_list=ALL_IDS)
names = [x[0] for x in cursor.description]
rows = results.fetchall()
からselect name from employee where id in ('101', '102', '103')
pythonの側では、私はこの('101', '102', '103')
のように文字列に変換し、Pythonで、次のコードを使用し、リスト[101, 102, 103]
を持っています。私は何か間違っているのですか?