Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

> 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
( 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

psycopg by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group