Re: psycopg2.extensions.adap

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Massimo Di Pierro <mdipierro(at)cs(dot)depaul(dot)edu>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: psycopg2.extensions.adap
Date: 2011-09-02 15:00:16
Message-ID: CA+mi_8bzRaO5tYCMGBEX2WYKyySLH+Enqb728Shv2XGSAmscRg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Fri, Sep 2, 2011 at 2:50 PM, Massimo Di Pierro
<mdipierro(at)cs(dot)depaul(dot)edu> wrote:

> 1) If I use psycopg2.extensions.adap(" \' ") do I get " ' " or " \'' "? In other words... does adapt know whether I set standrad_conformal_strings to on or off? How does it know that?

The SCS setting is communicated by the server to the client at
connection time. The setting is used by the libpq to encode the
strings using the proper escape style (using the PQescapeString
function). This function returns the escaped string without the
quotes: psycopg adds the quotes and, if required (if SCS is on) the E
too. As a result, everything should work regardless of the SCS
setting.

> 2) Is there a pure python distribution of psycopg2?

No: psycopg2 is a C extension. A few months ago Alex Gaynor ported
psycopg2 to pypy, I believe using ctypes to access the libpq from
python and, if I've understood correctly, mvantellingen is making this
ctypes porting a standalone package
(https://github.com/mvantellingen/psycopg2-ctypes). I haven't tested
any of these portings and I can't assess their
correctness/completeness (I've skimmed the latter's code and I think
the core part is in, but not a few secondary features. And as a first
glance I don't think it works with SCS=off). None of these package is
"pure", as they all wrap the C libpq library, but they do without C
code of their own. Pure Python drivers for Postgres do exist: they all
exhibit one ore more of the several shortcoming: slower, less
maintained, less tested, non-standard interface.

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Scott Rohde 2011-09-06 23:10:21 Re: psycopg2 and python built with ucs2
Previous Message Massimo Di Pierro 2011-09-02 13:50:37 psycopg2.extensions.adap