From: | Alan Evans <alanwevans(at)gmail(dot)com> |
---|---|
To: | psycopg(at)postgresql(dot)org |
Subject: | PQntuples for older version (2.2.1) of psycopg2 with ctypes |
Date: | 2016-02-19 23:34:39 |
Message-ID: | CAMFVOoWFa6w1nFU34gNFpVzA8UJ-wc=rW3Oa2imqub3Y6K1uhg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
I am using cursor.copy_expert and I would like to be able to use
cursor.rowcount but most of the systems I am targeting have older psycopg2
versions on them.
According to the following URL rowcount was updated for use with
copy_expert in 2.5.3...
https://psycopg.lighthouseapp.com/projects/62710/tickets/180-return-number-of-rows-for-copy-operations
Inspired by:
https://github.com/sunlightlabs/psycopg2-ctypes/blob/master/psycopg2ct/_impl/cursor.py
I wonder if it is possible to use ctypes to do this... Something like this
maybe:
import psycopg2
import ctypes
libpq = ctypes.CDLL('libpq.so.5')
conn = psycopg2.connect(foo)
cursor = conn.cursor()
cursor.copy_expert(bar)
rowcount = libpq.PQntuples(???)
I can "read" the psycopg2 source but I am not fluent. I am having trouble
working out what 'pgres' is. Is it the fileno() the backend_process_id()
etc...
So far all I have manged to do is segfault my python processes. Woot!
Is 'pgres' exposed by the Cursor or Connection classes somewhere?
Regards,
-Alan
From | Date | Subject | |
---|---|---|---|
Next Message | Jonathan Rogers | 2016-02-20 12:34:27 | Re: How to use "WHERE NOT EXISTS in INSERT STATEMENT" |
Previous Message | Serge Christian Ibala | 2016-02-19 20:00:59 | How to use "WHERE NOT EXISTS in INSERT STATEMENT" |