I\'m passing some values into a postgres character field using psycopg2 in Python. Some of the string values contain periods, slashes, quotes etc.
With MySQL I\'d ju
Psycopg2 doesn't have such a method. It has an extension for adapting Python values to ISQLQuote objects, and these objects have a getquoted()
method to return PostgreSQL-compatible values.
See this blog for an example of how to use it:
Quoting bound values in SQL statements using psycopg2
Update 2019-03-03: changed the link to archive.org, because after nine years, the original is no longer available.