[DB-SIG] API suggestion: expose 'quote' method
Kevin Jacobs
jacobs at penguin.theopalgroup.com
Tue Jun 3 15:33:05 EDT 2003
On Tue, 3 Jun 2003, Chris Cogdon wrote:
> I'm suggesting that we make this part of the API (2.1, perhaps) so that
> there's something there my application can depend on. I believe it's an
> important part of dealing with the DMBS, and should be part of the
> specs/requirements.
Why not implement it yourself for your own application? Implementing
generic quoting properly often requires that a fair amount of type-metadata
is available. It is more the job of a object/relational mapper than a
low-level DB-API driver, although a DB-API driver can do it with some help
from the backend. Please do not be mislead by some of the simplistic (and
wrong) implementations that you may find laying around.
Specifically, quoting strings (char and varchar), integers, and floats is
usually fairly easy -- just borrow the code or read the web docs. The pain
starts when you want to quote times, dates, booleans, numerics, money,
intervals, network types, etc. without knowing the schema type it will be
bound to beforehand.
For more insight into these complications, study ODBC for a while. It is a
good example of a broader and richer (but more painful) API than DB-API.
-Kevin
--
--
Kevin Jacobs
The OPAL Group - Enterprise Systems Architect
Voice: (216) 986-0710 x 19 E-mail: jacobs at theopalgroup.com
Fax: (216) 986-0714 WWW: http://www.theopalgroup.com
More information about the DB-SIG
mailing list