Обсуждение: [psycopg] Fetching data from binary cursor

Поиск
Список
Период
Сортировка

[psycopg] Fetching data from binary cursor

От
Tom Kazimiers
Дата:
Hi,

I am using Psycopg 2.7.1 from a Django application. To improve the
performance of some very large queries I want to test server-side binary
cursors and when I try to fetch results from it, I run into this error:

  rows = cursor.fetchall()
  ValueError: invalid literal for long() with base 10: ''

This is what I do:

  from django.db import connection

  cursor = connection.connection.cursor()
  cursor.execute('''
    DECLARE test_cursor BINARY CURSOR FOR
    SELECT * FROM treenode
  ''')
  cursor.execute("""FETCH 1 FROM test_cursor""")
  rows = cursor.fetchall()

The cursor I get from Django (connection.connection.cursor()) is a
genuine Psycopg2 cursor:

  > type(cursor)
  psycopg2.extensions.cursor

Is there something I am doing wrong?

Thanks,
Tom


Re: [psycopg] Fetching data from binary cursor

От
Daniele Varrazzo
Дата:
On Fri, Jul 21, 2017 at 7:49 PM, Tom Kazimiers <tom@voodoo-arts.net> wrote:
> Hi,
>
> I am using Psycopg 2.7.1 from a Django application. To improve the
> performance of some very large queries I want to test server-side binary
> cursors and when I try to fetch results from it, I run into this error:
>
>  rows = cursor.fetchall()
>  ValueError: invalid literal for long() with base 10: ''
>
> This is what I do:
>
>  from django.db import connection
>
>  cursor = connection.connection.cursor()
>  cursor.execute('''
>    DECLARE test_cursor BINARY CURSOR FOR
>    SELECT * FROM treenode
>  ''')
>  cursor.execute("""FETCH 1 FROM test_cursor""")
>  rows = cursor.fetchall()
>
> The cursor I get from Django (connection.connection.cursor()) is a genuine
> Psycopg2 cursor:
>
>  > type(cursor)
>  psycopg2.extensions.cursor
>
> Is there something I am doing wrong?

Psycopg doesn't support binary cursors.

-- Daniele


Re: [psycopg] Fetching data from binary cursor

От
Tom Kazimiers
Дата:
On Sat, Jul 22, 2017 at 01:26:23AM +0100, Daniele Varrazzo wrote:
>On Fri, Jul 21, 2017 at 7:49 PM, Tom Kazimiers <tom@voodoo-arts.net> wrote:
>> Is there something I am doing wrong?
>
>Psycopg doesn't support binary cursors.

Oh well… Sorry for the noise! Thanks for clearing this up!

Tom