Re: [PyGreSQL] prepared statements and EXECUTE parameters

2019-01-02 Thread Justin Pryzby
On Fri, Dec 21, 2018 at 05:58:43PM -0600, Justin Pryzby wrote: > On Fri, Dec 14, 2018 at 11:11:03AM -0600, Justin Pryzby wrote: > > I hacked query_formatted to accept an prepare=False. > > The difficulty is in replacing %s with $1, which needs to either have a > > list of > > parameters over

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-21 Thread Justin Pryzby
On Fri, Dec 14, 2018 at 11:11:03AM -0600, Justin Pryzby wrote: > Find attached patch with proof of concept for minimal implementation of > prepared statements. > And for PQexecPrepared, I added a conditional in query(), since that entire > function appears to be exactly what's needed for the

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-14 Thread Justin Pryzby
On Fri, Dec 14, 2018 at 11:11:03AM -0600, Justin Pryzby wrote: > Find attached patch with proof of concept for minimal implementation of > prepared statements. I was looking at what it would take to allow prepared statements in pgdb module, in addition to pg. I guess that's most of what you were

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-14 Thread Justin Pryzby
Find attached patch with proof of concept for minimal implementation of prepared statements. I hacked query_formatted to accept an prepare=False. The difficulty is in replacing %s with $1, which needs to either have a list of parameters over which to iterate, or at least an integer determining

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-14 Thread D'Arcy Cain
On 12/13/18 11:58 PM, Justin Pryzby wrote: > The link to the archives is still dead: > https://mail.vex.net/mailman/private.cgi/pygresql/ https://mail.vex.net/mailman/private/pygresql/ This is a bit more difficult because it happens inside Mailman. I tried searching for an answer but couldn't

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-14 Thread Justin Pryzby
On Fri, Dec 14, 2018 at 04:31:00PM +0100, Christoph Zwerschke wrote: > Am 14.12.2018 um 14:57 schrieb Justin Pryzby: > > Maybe it's easier than that.. > > I saw two issues. First, EXECUTE %s wasn't "adapted" to $1 (since > > there were no parameters passed). > > Second, execute failed with

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-14 Thread Christoph Zwerschke
Am 14.12.2018 um 14:57 schrieb Justin Pryzby: > Maybe it's easier than that.. > I saw two issues. First, EXECUTE %s wasn't "adapted" to $1 (since > there were no parameters passed). > Second, execute failed with inline=False. > But actually, SQL EXECUTE doesn't accept parameters, > they MUST be

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-14 Thread Justin Pryzby
On Sun, Dec 09, 2018 at 02:23:48PM -0600, Justin Pryzby wrote: > >>> d.query('prepare c AS INSERT INTO t VALUES($1)') -- note postgres $1 > >>> parameter > > But this fails: > > >>> d.query_formatted('EXECUTE c(%s)', [1]) On Thu, Dec 13, 2018 at 10:46:15PM +0100, Christoph Zwerschke wrote: >

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-14 Thread Christoph Zwerschke
Am 14.12.2018 um 01:55 schrieb Justin Pryzby: > Do you have any idea what the interface would look like for this ? > Would we add a prepare() and execute() ? > Or query(..., prepare='name') ? I'd prefer the former. We could then also add describe_prepared() and delete_prepared() (which would

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-13 Thread Justin Pryzby
On Thu, Dec 13, 2018 at 11:49:38PM -0600, D'Arcy Cain wrote: > On 12/13/18 4:10 PM, Christoph Zwerschke wrote: > > Am 13.12.2018 um 23:03 schrieb Justin Pryzby: > >> BTW, are the mailing list archives (still) public ?  I can't find them and > >> the > >> link is dead. > > > > D'Arcy, can you

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-13 Thread D'Arcy Cain
On 12/13/18 4:10 PM, Christoph Zwerschke wrote: > Am 13.12.2018 um 23:03 schrieb Justin Pryzby: >> BTW, are the mailing list archives (still) public ?  I can't find them >> and the >> link is dead. > > D'Arcy, can you have a look? They're on your server.

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-13 Thread Justin Pryzby
On Thu, Dec 13, 2018 at 10:46:15PM +0100, Christoph Zwerschke wrote: > unfortunately PyGres does not yet support prepared statements with parameter > passing. I think this can only be solved by adding support for > PQExecPrepared in the C module. Do you have any idea what the interface would look

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-13 Thread Christoph Zwerschke
Am 13.12.2018 um 23:03 schrieb Justin Pryzby: BTW, are the mailing list archives (still) public ? I can't find them and the link is dead. D'Arcy, can you have a look? They're on your server. -- Christoph ___ PyGreSQL mailing list PyGreSQL@vex.net

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-13 Thread Justin Pryzby
On Thu, Dec 13, 2018 at 10:46:15PM +0100, Christoph Zwerschke wrote: > unfortunately PyGres does not yet support prepared statements with parameter > passing. I think this can only be solved by adding support for > PQExecPrepared in the C module. Thank you. BTW, are the mailing list archives

Re: [PyGreSQL] prepared statements and EXECUTE parameters

2018-12-13 Thread Christoph Zwerschke
Hi Justin, unfortunately PyGres does not yet support prepared statements with parameter passing. I think this can only be solved by adding support for PQExecPrepared in the C module. I have now added a ticket for this: http://trac.pygresql.org:8000/pgtracker/ticket/76 -- Christoph

[PyGreSQL] prepared statements and EXECUTE parameters

2018-12-09 Thread Justin Pryzby
Hi, I've been wanting to implement prepared statements, not sure if that's considered to be supported by pygresql. I found that I can do: >>> import pg >>> d=pg.DB('ts') >>> d.query('prepare c AS INSERT INTO t VALUES($1)') -- note postgres $1 >>> parameter >>> d.query_formatted('EXECUTE c(1)')