I'm just getting started with PostgreSQL and have a bit of a problem. I am using Psycopg2 and hosting the PostgreSQL database on AWS RDS. Here is the query I am trying to execute:
cursor.execute('SELECT id FROM fqdn AS domain WHERE domain.fqdn IS {0}'.format(fqdn_str))
fqdn_str is a domain name like this:
https://www.example.com
and the fqdn table is this:
CREATE TABLE fqdn (
id SERIAL PRIMARY KEY,
fqdn TEXT NOT NULL,
date_last_crawled TIMESTAMP WITH TIME ZONE NOT NULL,
UNIQUE (fqdn)
);
The error I am getting is this:
psycopg2.ProgrammingError: syntax error at or near "https"
I have no idea what I am doing wrong so I would appreciate a little bit of help with this. If you need any more information then please let me know. Thank you.
Edit:
If I change the format string to %s as shown in the documentation I get the following error:
TypeError: not all arguments converted during string formatting

cursor.execute('SELECT id FROM fqdn AS domain WHERE domain.fqdn IS \'{0}\''.format(fqdn_str))cursor.execute('SELECT id FROM fqdn AS domain WHERE domain.fqdn IS %s', (fqdn_str))=instead ofIS?fqdn_strin the code you suggested in your comment. I added an answer with my reasoning.