Storing/Retrieving python raw strings in a database

Aahz Maruch aahz at netcom.com
Tue Aug 22 13:11:51 EDT 2000


[posted & e-mailed]

In article <3988420F.E870E1A6 at clickfeed.com>,
Laura Arbilla  <larbilla at clickfeed.com> wrote:
>
>This is what I'm doing:
>User types a regular expression (in python raw string syntax)
>in my html form, which is written in php:
>http://www\.foo\.com
>
>I store this reg exp in a mySQL database, the value in the database is:
>http://www\\.foo\\.com
>because single backslashes should be doubled when stored in mySQL.

I just did a quick check to see if mySQL is any different in this regard
from SQL Server (which is what I'm familiar with).  What you should be
doing here, is *not* escaping the backslash.  Just store it the way you
get it.  Use single quotes around the string that you send to mySQL, but
make sure to double any single quotes in the string first.  When you
read the string back, you should not need to make any modifications.
--
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

The difference between "intelligence" and "wisdom": Londo and G'Kar



More information about the Python-list mailing list