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

From Jeff Ross
Subject Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?
Date
Msg-id 92a8b8b9-2ea9-d079-de64-c18380f1bc11@openvistas.net
Whole thread Raw
In response to Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
On 11/3/22 2:42 PM, Daniele Varrazzo wrote:
> 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
> 
> 

Indeed that did fix the problem!

THANKS!!!!!

Jeff



psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: Can psycopg2 copy_expert read from an io.StringIO() buffer?
Next
From: Christopher Bader
Date:
Subject: Parquet support