Re: RPM question: Where to put psycopg2 files

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: RPM question: Where to put psycopg2 files
Date: 2011-01-17 13:35:38
Message-ID: AANLkTimNcRBbfQV0X5H8L=3YwPOgn86N5sWz1s4wUn0-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Mon, Jan 17, 2011 at 1:02 PM, Karsten Hilbert
<Karsten(dot)Hilbert(at)gmx(dot)net> wrote:
> On Mon, Jan 17, 2011 at 09:05:40AM +0100, Federico Di Gregorio wrote:
>
>> On 17/01/2011 07:59, Devrim GÜNDÜZ wrote:
>> > As of PostgreSQL 9.0+, PostgreSQL RPMs can be installed in parallel,
>> > e.g., you can use 9.0 along with 9.1. I updated most of the packages to
>> > use that layout, but I'm stuck with psycopg2.
>> >
>> > psycopg2 is currently installed under this directory:
>> >
>> > `python  -c "from distutils.sysconfig import get_python_lib; print
>> > get_python_lib(1)"`/psycopg2
>> >
>> > For example,
>> >
>> > /usr/lib64/python2.7/site-packages/psycopg2/
>> >
>> > If I want to install two different psycopg2 versions which are compiled
>> > against 9.0 and 9.1, they will overwrite each other.
>> >
>> > What is the best way to use separate directories for that? Is there a
>> > setup.py parameter for that?
>>
>> You don't need that, because psycopg uses libpq that can connect to
>> older versions of the backend.
>>
>> I don't know about RPMs but in Debian we have multiple versions of
>> postgresql and only *one* libpqXX package (usually it comes from the
>> most recent stable release). So my suggestion is to have only one
>> version of psycopg linked to the most recent libpq package.
>
> This is not really the final solution.
>
> I've got a Debian/Squeeze machine which runs PG 9.0 from /Unstable.
>
> I've got a second Debian/Squeeze machine running PG 8.4 from /Squeeze.
>
> Both use the same psycopg2 from /Squeeze.
>
> Transferring bytea data from the 9.0 machine to the 8.4 one
> does not work (other datatypes work fine).

Using a psycopg with libpq < 9 to talk with postgres >= 9 yes, there
is this problem. The other way around it works fine: psycopg+libpq 9
passes all the tests even with a 7.4 server.

The problem is that postgres 9 uses by default the hex format instead
of the escape format to represent bytea
(http://www.postgresql.org/docs/9.0/static/datatype-binary.html) A
workaround I was thinking about could be to send "SET bytea_output TO
'escape';" on connection in case of pre9-libpq/post9-server
combination is detected. I hate it because I was trying to drop the
"queries on connection" psycopg does (there used to be 3, now there is
only one and I think the last one can be dropped as well). Of course
bytea_output can be set in the postgresql.conf too and it would make
previous releases of psycopg work fine.

Bottom line is that currently only libpq 9.0 works fine to talk with a
9.0 server, unless bytea_output is set to 'escape' on the server.

-- Daniele

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Federico Di Gregorio 2011-01-17 13:53:16 Re: RPM question: Where to put psycopg2 files
Previous Message Karsten Hilbert 2011-01-17 13:31:55 Re: RPM question: Where to put psycopg2 files