Re: Can psycopg2 copy_expert read from an io.StringIO() buffer? - Mailing list psycopg

From Daniele Varrazzo
Subject Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?
Date
Msg-id CA+mi_8Yf6_cRgDjSuFt7px=g7=skjrx_73Pb3qBDwEiasEKgfQ@mail.gmail.com
Whole thread Raw
In response to Can psycopg2 copy_expert read from an io.StringIO() buffer?  (Jeff Ross <jross@openvistas.net>)
Responses Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?  (Jeff Ross <jross@openvistas.net>)
List psycopg
Hello Jeff,

On Thu, 3 Nov 2022 at 21:15, Jeff Ross <jross@openvistas.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



psycopg by date:

Previous
From: Jeff Ross
Date:
Subject: Can psycopg2 copy_expert read from an io.StringIO() buffer?
Next
From: Jeff Ross
Date:
Subject: Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?