PgSQL and double quotes...

Steve Holden sholden at holdenweb.com
Wed Dec 13 18:38:02 EST 2000


<karacim at my-deja.com> wrote in message news:914i7a$q0a$1 at nnrp1.deja.com...
> Hi,
> PgSQL doesn't seem to like the data that is
> sometimes in binary format and in somecases
> includes double/single quotes (ie "" or '' etc..)
> which causesng PgSQL to invoke parsing error...!
>
SQL data containing single quotes can be problematic, although you should
not experience any difficulty with double quotes.

> I wrote a simple class before the execute sintax
> as :
>   string.join(string.split(text, "'"), "''")
> but that still doesnt get rid of this "parsing
> error" from PgSQL... anyone has any ideas?
>
This seems to be a fairly convoluted way to write

    string.replace(text, "'", "''")

but appears to give the same result, at least in common cases (I didn't do
exhaustive testing).

This works for me using mxODBC to drive SQL Server 6.5 and 7.0, as well as
Access.  So I can only conclude that either it's the fact you're working
with bonary data or some implementation deficiency of PgSQL (not, I must
say, a system I am familiar with).

> thx
>
> Aus
>

A small code example might allow the group to exercise its collective mind a
little more creatively on solving your problem, if you can isolate the
problem to a ten- or twenty-line test case.

regards
 Steve







More information about the Python-list mailing list