For given a table
create table test_db (
id uuid
)
In Python with library psycopg2, we can do query
cursor.execute("select * from test_db where id in" +
" ('5ed11bbf-ffd1-4124-ba3d-5e392dc9db96','14acfb5b-3b09-4728-b3b3-8cd484b310db')")
But if I parameterize id
, change to
cursor.execute("select * from testdb where id in (%s)",
("'5ed11bbf-ffd1-4124-ba3d-5e392dc9db96','14acfb5b-3b09-4728-b3b3-8cd484b310db'",))
It's not working, says
psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type uuid: "'5ed11bbf-ffd1-4124-ba3d-5e392dc9db96','14acfb5b-3b09-4728-b3b3-8cd484b310db'"
How can I use in (%s)
with uuid array?