Re: Prepared statements [was: Session state per transaction]

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: Prepared statements [was: Session state per transaction]
Date: 2012-09-28 10:57:50
Message-ID: CA+mi_8aOb0O_s-To+k8b+rTQnfPEia7GTYtCCt=zefw0Kxobyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Fri, Sep 28, 2012 at 11:33 AM, Karsten Hilbert
<Karsten(dot)Hilbert(at)gmx(dot)net> wrote:
> On Fri, Sep 28, 2012 at 02:32:42AM +0100, Daniele Varrazzo wrote:
>
>> I've played a little bit with the idea and made a cursor subclass
>> instead: it does everything like a normal cursor, but has a prepare()
>> method. If it is called, execute() and executemany() can be called
>> without a query, in which case they execute the statement stored (the
>> cursor can have only one, but several cursors can be used to prepare
>> several statements). If execute*() receive a query too they behave
>> like normal cursors
>
> Maybe check the received query string against the already
> prepared query string and on match reuse the prepared query ?

Yes, it could make easier to drop it into already existing code.

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Ryan Kelly 2012-09-28 19:01:09 segmentation faults with psycopg2 and multiprocessing
Previous Message Karsten Hilbert 2012-09-28 10:33:41 Re: Prepared statements [was: Session state per transaction]