| Store | Cart

escape single and double quotes

From: Leif B. Kristensen <abu...@solumslekt.org>
Thu, 24 Mar 2005 15:57:51 +0100
I'm working with a Python program to insert / update textual data into a
PostgreSQL database. The text has single and double quotes in it, and I
wonder: What is the easiest way to escape quotes in Python, similar to
the Perlism "$str =~ s/(['"])/\\$1/g;"?

I tried the re.escape() method, but it escapes far too much, including
spaces and accented characters. I only want to escape single and double
quotes, everything else should be acceptable to the database.
-- 
Leif Biberg Kristensen
http://solumslekt.org/

Recent Messages in this Thread
Leif B. Kristensen Mar 24, 2005 02:57 pm
Jiri Barton Mar 24, 2005 03:06 pm
Damjan Mar 24, 2005 03:24 pm
Leif B. Kristensen Mar 24, 2005 03:56 pm
Scott David Daniels Mar 24, 2005 05:48 pm
Marc BlackJack Rintsch Mar 24, 2005 06:25 pm
Leif B. Kristensen Mar 24, 2005 07:16 pm
Kent Johnson Mar 24, 2005 11:02 pm
Messages in this thread