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:
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