I want to execute this sql via psyopg2:
select indexname from pg_indexes where (tablename, indexname) in (
('tab1', 'index1'),
('tab2', 'index2')
);
Here is the code:
cursor.execute(
'select tablename, indexname from pg_indexes where (tablename, indexname) IN %s;', [
[('tab1', 'col1'), ('tab2', 'col2')],
])
I get this exception:
ProgrammingError: syntax error at or near "ARRAY"
LINE 1: ...e from pg_indexes where (tablename, indexname) IN ARRAY[('ta...
How to pass a list of PostgreSQL tuples to psyopg2?
source
share