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

From: Jeff Ross <jross(at)openvistas(dot)net>
To: psycopg(at)lists(dot)postgresql(dot)org
Subject: Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?
Date: 2022-11-03 21:44:41
Message-ID: 92a8b8b9-2ea9-d079-de64-c18380f1bc11@openvistas.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 11/3/22 2:42 PM, Daniele Varrazzo wrote:
> 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
>
>

Indeed that did fix the problem!

THANKS!!!!!

Jeff

In response to

Browse psycopg by date

  From Date Subject
Next Message Christopher Bader 2022-11-23 18:49:01 Parquet support
Previous Message Daniele Varrazzo 2022-11-03 20:42:01 Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?