Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqi18-00081a-E7 for psycopg@arkaria.postgresql.org; Thu, 03 Nov 2022 21:44:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oqi16-0005zQ-2a for psycopg@arkaria.postgresql.org; Thu, 03 Nov 2022 21:44:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqi15-0005zH-Rw for psycopg@lists.postgresql.org; Thu, 03 Nov 2022 21:44:51 +0000 Received: from luna.openvistas.net ([207.158.15.156] helo=openvistas.net) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oqi10-0002W3-Ji for psycopg@lists.postgresql.org; Thu, 03 Nov 2022 21:44:50 +0000 Received: (qmail 15799 invoked from network); 3 Nov 2022 21:44:42 -0000 Received: from unknown (HELO ?10.0.26.32?) (jross@154.27.106.60) de/crypted with TLSv1.3: AEAD-AES128-GCM-SHA256 [128/128] DN=none by mail.openvistas.net with ESMTPSA; 3 Nov 2022 21:44:42 -0000 Message-ID: <92a8b8b9-2ea9-d079-de64-c18380f1bc11@openvistas.net> Date: Thu, 3 Nov 2022 15:44:41 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: Can psycopg2 copy_expert read from an io.StringIO() buffer? Content-Language: en-US To: psycopg@lists.postgresql.org References: <6dfed0bf-a52a-66c0-43a9-6258d7b9843b@openvistas.net> From: Jeff Ross In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/3/22 2:42 PM, Daniele Varrazzo wrote: > Hello Jeff, > > On Thu, 3 Nov 2022 at 21:15, Jeff Ross 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