My problem was this?

value = " '\' "
connection  = psycopg2.Connect(....)
cursor = connection.cursor()
curser.execute('set normal_conformal_string=on;")
cursor.execute("INSERT INTO TABLE(FIELD) VALUES(%s);",value) #1
curser.execute('set normal_conformal_string=off;")
cursor.execute("INSERT INTO TABLE(FIELD) VALUES(%s);",value) #2

How does psycopg2 knows it needs to escape #1 and #2 differently? Same
problems applies to the adapt function.

I found the answer here: 
http://www.postgresql.org/docs/8.3/static/libpq-status.html

<quote>
Certain parameter values are reported by the server automatically at
connection startup or whenever their values change.
...
Parameters reported as of the current release include server_version,
server_encoding, client_encoding, is_superuser, session_authorization,
DateStyle, TimeZone, integer_datetimes, and
standard_conforming_strings. (server_encoding, TimeZone, and
integer_datetimes were not reported by releases before 8.0;
standard_conforming_strings was not reported by releases before 8.1.)
</quote>

Thanks again for your help. It helped us look into this in more detail
than we did before and web2py is better/safer as a result.

Massimo



On Sep 2, 9:41 pm, nick name <[email protected]> wrote:
> psycopg uses a Postgres provided routine to escape the strings, which is
> aware of what version of postgres is at the other end of the connection
> (apparently since library shipped with 8.1.4, if I can read the source
> correctly): Link to relevant psycopg file is 
> here<https://dndg.it/cgi-bin/gitweb.cgi?p=public/psycopg2.git;a=blob;f=psy...>
> .
>
> Massimo - thanks again for web2py, and for running the project so awesomely!

Reply via email to