psycopg2.extensions.adap

Поиск
Список
Период
Сортировка
Искать

psycopg2.extensions.adap

От:
Massimo Di Pierro <mdipierro@cs.depaul.edu>
Дата:
Hello everybody,

First of all thank you for Psycopg2

I have two questions:

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?

2) Is there a pure python distribution of psycopg2?

Massimo


Re: psycopg2.extensions.adap

От:
Daniele Varrazzo <daniele.varrazzo@gmail.com>
Дата:
On Fri, Sep 2, 2011 at 2:50 PM, Massimo Di Pierro
 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
FAQ