Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Jeff Ross <jross(at)openvistas(dot)net>
Cc: psycopg(at)lists(dot)postgresql(dot)org
Subject: Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?
Date: 2022-11-03 20:42:01
Message-ID: CA+mi_8Yf6_cRgDjSuFt7px=g7=skjrx_73Pb3qBDwEiasEKgfQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hello Jeff,

On Thu, 3 Nov 2022 at 21:15, Jeff Ross <jross(at)openvistas(dot)net> wrote:

> publisher_copy_cursor.copy_expert(copy_query,csv_buf,size)
> subscriber_copy_cursor.copy_expert(insert_query,csv_buf)

Yes, StringIO works ok with copy_expert(). I think you need a
csv_buf.seek(0) between these two statements: after copying data in
the file, the file pointer will be at the end.

Cheers

-- Daniele

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Jeff Ross 2022-11-03 21:44:41 Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?
Previous Message Jeff Ross 2022-11-03 20:15:11 Can psycopg2 copy_expert read from an io.StringIO() buffer?