[DB-SIG] How to know what to do with parameters...

Magnus Lyckå magnus at thinkware.se
Fri May 16 23:24:00 EDT 2003


At 12:37 2003-05-16 -0400, Kevin Jacobs wrote:
>On Fri, 16 May 2003, Magnus Lyckå wrote:
> > I would like to suggest that the DB-API will stipulate
> > that the DBinterfaces should check whether an object has
> > a method of a certain, standardized name, and use that
> > method to extract the stringified value to put in the
> > SQL statement, it the object has such a method.
>
>This assumes that objects will only need to know how to encode themselves
>for a single known backend, or that all possible backends can rely on a
>single encoding.

Not really, although that would be good enough in many
cases.

I'm not claiming that this is a silver bullet that will
solve all problems. Most cross platform problems in SQL
doesn't have anything with parameter passing to do at all,
and I can well imagine that some parameter passing problems
are trickier than others...

I think that simply being able to write a small method
like "return "'%.2f'" % self.amt" would be useful in some
instances.

Apart from that, there are certainly possibilities beyond
what you describe.

For instance, the method in the value object might return
different strings for different backends.

Also, if a particular backend interface knows that certain
types of data have to be handled in a particular way on that
platform, it can post-process the data it got from the
_dbapi_value() method call. I suppose some meta data like
proposed by Anthony would be useful there.

So it's not as limited as you seem to think.

We're only talking about parameter passing here. It's not
like we're trying to write SQL 92 code regardless of backend.
That is certainly beyond the scope of my suggestion, and I'm
curious to see what the Opal Group will offer in this area.

Of course, with the applications I worked with that used many
different backends in different installations, we didn't use
all the bells and whistles of all the involved databases. We
did use a least common denominator, but that worked pretty
well. After all, most applications only require a fraction of
the features in most backends...

>If it were that easy, it would have already been done.  However, it is not
>an intractible problem, though it does _very_ quickly escape the scope of
>DB-API and deserves a distinct API layer of its own.

But I don't see that distinct API layer materializing.


--
Magnus Lycka (It's really Lyckå), magnus at thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program 




More information about the DB-SIG mailing list