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

Re: Psycopg2 and LIXA

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Christian Ferrari <camauz(at)yahoo(dot)com>
Cc: "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: Psycopg2 and LIXA
Date: 2012-02-13 09:10:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: psycopg
On Sun, Feb 12, 2012 at 10:02 PM, Christian Ferrari <camauz(at)yahoo(dot)com> wrote:

> I briefly examined DBAPI, but unfortunately there is a major drawback: DBAPI supplies an API that is equivalent to XA and can be used to implement a Transaction Manager, but it should not be used by an Application Program. If an Application Program had to deal with "prepare" and "recover" verbs, it would implement a Transaction Manager itself.

Isn't LIXA a Transaction Manager, and as such supposed to use the
tpc_*() methods, while an application would use the other connection

>> I suspect a good solution could be for
>> the lixa code to create a psycopg connection (which in turn calls
>> PQconnectdb) and get the PGconn from there, then returning the python
>> object to the invoking python code. Also, because lixa seems modular,
>> couldn't you create a "psycopg" module, which would largely use
>> the
>> same "postgresql" module implementation but would offers methods that
>> are meaningful for a Python user (i.e. return a connectionObject
>> instead of a PGconn)?
> Wrapping "lixa_pq_get_conn()" (that's C code) with a method retrieving a different type could be done at C level and Python level as well. Where could I found the exact "connectionObject" specification? Could you point me to the right direction at first step?

An example of creation of a connection is the psyco_connect() function
in psycopgmodule.c: the most accessible way in C would be

    connectionObject *conn
    conn = (connectionObject *)PyObject_CallFunction((PyObject
*)&connectionType, "s", dsn);

where dsn is the char[] containing the libpq connection string.

I assume the function should be called with a Python interpreter well
initialized, but if lixa is imported by a Python process and the above
code is called by a function wrapped in a Python call I assume all the
conditions required are met. Of course everything is pretty
experimental: psycopg doesn't offer (yet) a C api, nor the import
file are designed to be used outside the library: if the approach
works we can provide a Python C API properly done.

-- Daniele

In response to


psycopg by date

Next:From: Federico Di GregorioDate: 2012-02-13 09:17:24
Subject: Re: Psycopg2 and LIXA
Previous:From: Federico Di GregorioDate: 2012-02-13 08:52:26
Subject: Re: Psycopg2 and LIXA

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