Psycopg2 single quote exception

Viewed 7162

I use psycopg2 for my application. Everything is fine but this: When i insert a data includes single quote ' then python throw the exception below:

<class 'psycopg2.ProgrammingError'>: syntax error at or near "s"

and the content is like this "Kid's page"

I could not find a solution to fix this issue. I use python string literals like:

"""INSERT INTO table (field_name) VALUES ('%s');"""

I catch exception and return the query. I run this query from posgtre shell and it works fine. What is wrong with psycopg2?

3 Answers
Related