[DB-SIG] PEP249 - Proposed change to DB-API 2.0

Chris Cogdon chris@cogdon.org
Fri, 27 Apr 2001 01:47:16 -0700 (PDT)


On Fri, 27 Apr 2001, Federico Di Gregorio wrote:

> i don't understand. the following code (taken from psycopg)
> implements *both* format and pyformat:
>
>     query = PyString_Format(str, dict_or_tuple)
>
> that wotks both with %(name)s stype and a dict or %s stype and a tuple.

Thats excellent, unfortunately the DB API as it stands has no way of
advertising the fact that it could support both paramstyles.

> sometimes it is much easier to format a full query string and simply
> pass it to the C library, as we did.

Agreed. I've only seen the wrappers for MySQL and PostgreSQL, and that's
what they seem to do. If the C API can support this, then you can easily
turn /any/ paramstyle into this string, and I cant see much SQL parsing
being required (see my other post for the reference to a quick and dirty
function I wrote to do this)

> lack of time of the authors? we implemented the two param styles most
> used, others will follow when somebody will request them or when i'll
> have some free time... :)

The issue I wanted to raise first was the lack of support for even
/reporting/ that it can be done in the API spec, which at the moment
assumes that the API writer will only ever write one calling method.

> a well-written piece of C code that takes the args in python form
> (the ones you give to PyArgs_ParseTuple) and parse any of the four
> formats spitting out the query string will be much welcome...

If you hadn't said 'well written', and 'C', I'd say 'Done' :)


   ("`-/")_.-'"``-._        Chris Cogdon <chris@cogdon.org>
    . . `; -._    )-;-,_`)
   (v_,)'  _  )`-.\  ``-'
  _.- _..-_/ / ((.'
((,.-'   ((,/   fL