How to quote text before inserting into database?

From: Scott Chapman <scott_list(at)mischko(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to quote text before inserting into database?
Date: 2003-10-18 04:29:40
Message-ID: 200310172129.40718.scott_list@mischko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am working with Python (psycopg). I have HTML with embedded Python that I'm
inserting into a database and it could contain any character.

Single quotes, at least, must be escaped (to two single quotes, right?) before
inserting it into Postgres.

This poses a problem when I get the data out of the table. It could have
originally contained two single quotes together and I replace them with one
single quote in the unescaping process.

How do you properly escape the special characters (and what all are they)?

TIA,
Scott

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2003-10-18 04:53:40 Re: VACUUM degrades performance significantly. Database
Previous Message Tom Lane 2003-10-18 03:49:30 Re: Using subselects in INSERTs?