Re: Psycopg2 and LIXA
От | Daniele Varrazzo |
---|---|
Тема | Re: Psycopg2 and LIXA |
Дата | |
Msg-id | CA+mi_8bzLLSHgGD_gRCvNudD-g5Zcm-8NpuF0cb1-t7U3B0eHw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Psycopg2 and LIXA (Christian Ferrari <camauz@yahoo.com>) |
Ответы |
Re: Psycopg2 and LIXA
|
Список | psycopg |
On Sun, Feb 12, 2012 at 10:02 PM, Christian Ferrari <camauz@yahoo.com> wrote: > I briefly examined DBAPI, but unfortunately there is a major drawback: DBAPI supplies an API that is equivalent to XA andcan be used to implement a Transaction Manager, but it should not be used by an Application Program. If an ApplicationProgram 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 methods? >> 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 Pythonlevel as well. Where could I found the exact "connectionObject" specification? Could you point me to the right directionat 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
В списке psycopg по дате отправления: