Hello,

lately there has been some interest in adding prepared statements
support in Psycopg. It's a feature of which I see the usefulness but
which I haven't used extensively enough to make my mind about be the
best interface to present it to the driver clients.

A toy prototype that hasn't lead to a great deal of discussion is
described in this article:
<http://initd.org/psycopg/articles/2012/10/01/prepared-statements-psycopg/>.
This implementation is explicit: the cursor has a prepare() method and
execute can be run without the statement, only with the parameters,
which would call the prepared statements.

Other implementations are possible of course. A cursor may prepare
automatically a statement and then execute it, but this adds a network
roundtrip, uses more server resources and can lead to suboptimal plans
(because the planner doesn't know the parameter so can't decide about
a filter selectivity etc.). A cursor may support a single prepared
statement or many, in which case a cache invalidation policy could be
needed etc.

I was wondering a few things:

- is there enough consensus - not only in the Python world - about how
to implement a prepared statements interface on a db driver?
- do other Python drivers implement stored procedures? Do they do it
in a uniform way?
- is the topic generic enough for the DB-SIG to suggest a DB-API
interface or is it too database specific and the interface would be
better left to the single driver?

Thank you very much for any help provided.

-- Daniele
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
https://mail.python.org/mailman/listinfo/db-sig

Reply via email to