Re: Escaped apastrophes
Gerhard Häring <[email protected]>
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Organization | OPUS GmbH |
| Message-ID | <[email protected]> |
In article <[email protected]>, Mike Barrett wrote: > Howdy, so here's my problem: I've got a database with a bunch > of info in it. One of the fields is a 'text' field. Whenever > I extract data from this field it seems to work out fine, > however, this isn't the case whenever there are both > apastrophies and double-quotes in the text. If both appear > inside the field, then all of the apastrophies are escaped with > a single backslash. Can't reproduce that here (pyPgSQL 2.2): *Schema:* gerhard=# \d test Table "test" Column | Type | Modifiers --------+------+----------- a | text | *Code:* from pyPgSQL import PgSQL con = PgSQL.connect(host="localhost", database="gerhard", user="gerhard") cursor = con.cursor() x = """Hello, "pyPgSQL" user! What's up?""" cursor.execute("insert into test(a) values (%s)", (x,)) cursor.execute("select a from test where oid=%s", (cursor.oidValue,)) row = cursor.fetchone() assert(row.a == x) con.close() Can you provide a test case that demonstrates the problem? > Any idea why it's doing this? Any idea how I can change this > behavior? Maybe a PgUnQuoteString-like method or something? Nah. This should work transparently. No need to use the low-level methods once you're using PgSQL. -- Gerhard Häring OPUS GmbH München Tel.: +49 89 - 889 49 7 - 32 http://www.opus-gmbh.net/ ------------------------------------------------------- This sf.net email is sponsored by: Are you worried about your web server security? Click here for a FREE Thawte Apache SSL Guide and answer your Apache SSL security needs: http://www.gothawte.com/rd523.html