I am using cx_Oracle to query my databse with Python. I have a query that returns multiple results. In cx_Oracle using the .fetchall() command on a query that returns multiple results puts each row into a tuple, and then makes a list of tuples (1 for every returned row). After fetching the results of my query it is formatted like this:
[('R100',), ('R200',)]
I now want to use those results in another query. The next query is as follows:
base_query = "select MODEL from USER.TABLE where SERIES in :series"
where :series is a special parameter marker that can be substituted when you execute the query like this:
cursor.execute(base_query, series=[('R100',), ('R200',)])
When I attempt to set series to my list of tuples I get this error:
cx_Oracle.NotSupportedError: element 0 value is unsupported
I understand that this is probably a syntax issue since in raw SQL what I am trying to to is probably creating a query that reads like this:
base_query = "select MODEL from USER.TABLE where SERIES in [('R100',), ('R200',)]"
when what I actually want is this:
base_query = "select MODEL from USER.TABLE where SERIES in ('R100','R200')
I am having trouble making the parsed raw query look like the second example though because I am unsure as to how python data types are being interpreted (I am guessing my 1st example isn't even a correct interpretation of what the raw SQL looks like)
UPDATE:
So I think you are supposed to be able to do this using by doing:
cursor.executemany(base_query, [('R100',), ('R200',)])
But I am getting an error: cx_Oracle.DatabaseError: DPI-1013: not supported
I am on cx_oracle Ver 7.0.0 trying to figure out what version my DB is now