[DB-SIG] Optional DB API Extensions

Stuart Bishop zen@shangri-la.dropbear.id.au
Thu, 25 Oct 2001 20:52:20 +1000


On Wednesday, October 24, 2001, at 01:04  AM, M.-A. Lemburg wrote:

> Title: Optional Database API Extensions

I would call this DB API 2.1 to avoid confusion, or if all the
methods do end up being optional, simply updating the existing
DB API 2.0 PEP. I think it is important that the current
specification ends up in a single document, as opposed to being
split up into two separate PEP's.

I also would like the connection method:
         quote(object)

             Returns a SQL quoted version of the given variable as a
             string, suitable for execution by the database backend.
             For example:

                 >>> print con.quote(42)
                 42
                 >>> print con.quote("Don't do that!")
                 'Don''t do that!'
                 >>> print con.quote(time.time())
			  TO_DATE('01-Jan-2001 12:01','DD-MMM-YYYY H24:MI')

I'd also add cursor methods for Python 2.2 iterators:

         next()

             Return the next row from the currently executing SQL 
statement.
             A StopIteration exception is raised when the result set is 
exhausted.
             This method will raise a NameError exception if run under 
versions of
             Python earlier than Python 2.2.


         __iter__()

             Returns self.

Another optional method may be a call to have the fetchXXX methods return
dictionaries rather than sequences, as this seems to be a common 
extension
and feature request.

Is it worth adding the transaction isolation level stuff I outlined in
the DB API 3 strawman I put out a month or two ago? There didn't appear
to be much interest in these, but I may be wrong. (I will be getting
around to replying to the last round of comments on  the 3.0 strawman
soon, as I have spare time again as of today).

Anyway, the proposal seems good from my point of view. Thanks for
the effort :-)

--
Stuart Bishop <zen@shangri-la.dropbear.id.au>
http://shangri-la.dropbear.id.au/