pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Weatherby,Gerard <gweatherby@uchc.edu>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: execute_values
Date: Wed, 10 Jul 2019 12:09:52 +0000
Message-ID: <1562760592312.53576@uchc.edu> (raw)
In-Reply-To: <83543627-3dc3-0a55-e23b-4f6dba55660f@aklaver.com>
References: <d5ef502864624af7ab88d13d021d88dd@NSO-ITEXC-MB25.uchc.net>
	<83543627-3dc3-0a55-e23b-4f6dba55660f@aklaver.com>

My insert has a "returning clause," I don't think execute batch supports that.

--
Gerard Weatherby| Application Architect
NMRbox | Department of Molecular Biology and Biophysics | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
Phone: 860 679 8484
uchc.edu

________________________________________
From: Adrian Klaver <adrian.klaver@aklaver.com>
Sent: Tuesday, July 9, 2019 4:25 PM
To: Weatherby,Gerard; pgsql-general@lists.postgresql.org
Subject: Re: execute_values

On 7/9/19 11:04 AM, Weatherby,Gerard wrote:
> ​Can I use pyscopy2.extras.execute_values with a prepared statement?

I don't think so as you cannot pass in VALUES():

cur.execute('prepare pt(integer, varchar, boolean) AS INSERT INTO
prepare_test values ($1, $2, $3)')

execute_values(cur, 'EXECUTE pt(%s)', [(2, 'test', 'f'),])

SyntaxError: wrong number of parameters for prepared statement "pt"
DETAIL:  Expected 3 parameters but got 1.


execute_batch works though:

execute_batch(cur, 'EXECUTE pt(%s, %s, %s)', [(2, 'test', 'f'), (3,
'dog', 't')])


>
>
> --
> *Gerard Weatherby*| Application Architect
> NMRbox | Department of Molecular Biology and Biophysics | UConn Health
> 263 Farmington Avenue, Farmington, CT 06030-6406
> Phone: 860 679 8484
> uchc.edu


--
Adrian Klaver
adrian.klaver@aklaver.com


view thread (4+ messages)  latest in thread

Message-ID: <1562760592312.53576@uchc.edu>
Permalink:  ../1562760592312.53576@uchc.edu/
Also on:    postgresql.org/message-id/1562760592312.53576@uchc.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: gweatherby@uchc.edu
  Subject: Re: execute_values
  In-Reply-To: <1562760592312.53576@uchc.edu>
  References: <d5ef502864624af7ab88d13d021d88dd@NSO-ITEXC-MB25.uchc.net> <83543627-3dc3-0a55-e23b-4f6dba55660f@aklaver.com> <1562760592312.53576@uchc.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox