I am having trouble inserting text with single quotes into Postgres DB using psycogp2. This is the error I get whenever it encounters text with single quotes.
psycopg2.errors.UndefinedColumn: column "dept of health (department), in consul" does not exist
When I removed the single quotes in the text.. the record was inserted without any issue.
Here's my query:
query = "INSERT INTO %s VALUES %s ON CONFLICT (id) DO UPDATE SET %s;" % (name, tuple(row), ', '
''.join(update_string))
I have tried the solutions mentioned in this link like replacing a single quote with a double-quote and escaping the single quote but still have the issue.