I've spent a good hour or so googling and trying various combinations but without success.
I wish to select from a table where one of the columns is single dimensional array of varchar(255).
In normal SQL I use the following query:
SELECT * FROM customers WHERE email_domains @> '{"@google.com"}';
That works perfectly. But now I want to do the same from code. So I have tried this:
domain = '@google.com'
sql = "SELECT * FROM customers WHERE email_domains @> '{%s}';"
cursor.execute( sql, [domain] )
result = cursor.fetchall()
and a whole load of various combinations of escaped ' and " but I cannot get it to work.
The error I get is this:
ERROR: malformed array literal: "{"
LINE 1: ... * FROM customers WHERE email_domains @> '{'@goo....
^
DETAIL: Unexpected end of input.
All help appreciated :)