Re: Integration of Psycopg with XTA

From: Christian Ferrari <camauz(at)yahoo(dot)com>
To: "psycopg(at)lists(dot)postgresql(dot)org" <psycopg(at)lists(dot)postgresql(dot)org>
Subject: Re: Integration of Psycopg with XTA
Date: 2018-09-29 20:28:53
Message-ID: 1079897705.1369958.1538252933975@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Today I have been able to manage the first transaction with XTA/Python/PostgreSQL using the hack you suggested some days ago: I have bypassed SWIG pointer restriction exposing a dedicated method from C++, with an "unsigned long long" to collect the "int" value generated by your hack in the Python space.I'm going to better understand PyCapsule in the next few days.Kind RegardsCh.F.

Il giovedì 27 settembre 2018, 21:57:52 CEST, Christian Ferrari <camauz(at)yahoo(dot)com> ha scritto:

Thanks, for the fix, now the function works, but unfortunately it's a dead end in the SWIG realm...Here's the statement: http://www.swig.org/Doc2.0/SWIGDocumentation.html#Python_nn18[...]
However, the inverse operation is not possible, i.e., you can't build a SWIG pointer object from a raw integer value.
[...]

PyCapsule https://docs.python.org/2/c-api/capsule.html, suggested by Federico seems a more viable approach:https://bfroehle.com/2011/07/18/python-capsules/
If Psycopg was able to retrieve a PyCapsule, XTA should be able to use it and the Python interpreter would be a gateway between two C/C++ distinct modules (Psycopg and XTA).I'm going to perform some experiments in the XTA wrapper before coming back to this mail thread.
Kind RegardsCh.F.

Il giovedì 27 settembre 2018, 16:41:07 CEST, Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> ha scritto:

On Wed, Sep 26, 2018 at 9:36 PM Christian Ferrari <camauz(at)yahoo(dot)com> wrote:
>
> Dear Daniele,
> thank you for providing the hack: it's a starting point to check integration feasibility.
> Unfortunately it does not work in my environment:
> Ubuntu LTS 14.04 64 bit
> python 2.7.6

>  File "pqconn_hack.py", line 24, in getpqconn
>    pqconn = htonl(int(hex[ver_off + 8:ver_off + 16], 16))
> TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'

This is an error: it should have been 'mem' instead of 'hex':

    pqconn = htonl(int(mem[ver_off + 8:ver_off + 16], 16))

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Christian Ferrari 2018-10-02 20:07:50 Re: Integration of Psycopg with XTA
Previous Message Akshay Joshi 2018-09-28 12:13:41 psycopg2 conn.poll() hangs when used with sshtunnel