PQntuples for older version (2.2.1) of psycopg2 with ctypes

Поиск
Список
Период
Сортировка
От Alan Evans
Тема PQntuples for older version (2.2.1) of psycopg2 with ctypes
Дата
Msg-id CAMFVOoWFa6w1nFU34gNFpVzA8UJ-wc=rW3Oa2imqub3Y6K1uhg@mail.gmail.com
обсуждение исходный текст
Ответы Re: PQntuples for older version (2.2.1) of psycopg2 with ctypes
Список 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:

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

В списке psycopg по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Using pgAdminIII to view the data written in PostGreSQL
Следующее
От: Serge Christian Ibala
Дата:
Сообщение: How to use "WHERE NOT EXISTS in INSERT STATEMENT"