2
Ich bin frustriert, eine Python-Liste an eine Oracle WHERE-Klausel zu übergeben. Ich verwende cx_Oracle, hier ist mein Code:Python-Liste übergeben Orakel Where-Klausel CX_Oracle
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import cx_Oracle
con = cx_Oracle.connect(str('user/[email protected]/orcl'))
cursor = con.cursor()
ids = [19 , 87 , 84]
cursor.execute(str("select employee_id , first_name , last_name from employees where employee_id in ('"+ids+"')"))
people = cursor.fetchall()
print people
'''The following code works for me , but the problem is the string formater placeholer is not gonna be static is dynamic.'''
params = (198 , 199)
cursor.execute(str("select employee_id , first_name , last_name from employees where employee_id in ('%s' , '%s')" %(params)))
'''Also it would be valid if i can create dynamically the string formater placeholder depending on "length of something".
Sorry if this question was answered i spend hours searching the solution , but i do not found it.'''