[DB-SIG] DB-API Spec. 1.1a1
Greg Stein (Exchange)
gstein@exchange.microsoft.com
Sun, 7 Dec 1997 06:49:57 -0800
I don't believe there is really any need for new date/time handling at
the database module level. One of the purposes of the DBI module was to
handle this specific problem.
1a) when a fetch is done, how do you differentiate a date from an
integer or float? Using a tuple is possible here, but they are harder to
work with than the integer/float (time_t) format. Instead, fetch returns
an instance of dbi.dbiDate, with its "value" attribute set to an
integer/float Python object.
1b) when an insert is done, how do you differentiate a date from
something else? Again, you could use a tuple, but you could then run
into a problem differentiating between inserting multiple dates vs.
inserting multiple rows of one date each. The answer is using
dbi.dbiDate instances and extracting the value attribute.
Note: in most databases, you must know the input binding type a priori
before the binding occurs. That is why you need to know the type before
inserting.
2a) when a fetch is done, how do you diffentiate a string from a
LONG/BLOB/whatever? Of course, representing those as a string is quite
handy. This can go either way, but 2b (below) implies that you want to
use a custom type: dbi.dbiRaw for these
2b) when an insert is done, you need to diffentiate between a string and
a LONG/BLOB. Here, you definitely can't use a string. The answer is to
use dbi.dbiRaw and extract the value from it.
The mechanism of using custom types for dates and longs/blobs as
indicators for insert (and partially for fetch) was solved by using the
dbi module.
I would recommend that if you want different date/time formats, that you
simply implement new methods on the dbiDate instances. Better yet, just
relegate that work to Python layers. Bill is quite on the mark when he
says to avoid imposing extra work on database implementors. One single
format is preferable.
[ although, I'm not sure where the heck he was going with the date
module concept since dbiDate represents the type that he's looking for.
]
-g
_______________
DB-SIG - SIG on Tabular Databases in Python
send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
_______________