[DB-SIG] DB API 2.0... what about NULLs ?

Andy Dustman adustman@comstar.net
Thu, 15 Apr 1999 13:19:15 -0400 (EDT)


On Thu, 15 Apr 1999, M.-A. Lemburg wrote:

> The updated version is on my Python Pages. It only contains a
> mention of using None as NULL. The alias part is gone. BTW,
> the idea was not to actually use the alias in execute()s, but
> to be able to test whether the database knows about NULLs.

Oh, well that's another matter. On one hand, the cursor description will
tell you what columns are nullable. On the other, this doesn't necessarily
tell you if the database allows NULL columns. I see three immediate
possibilities:

1) a module attribute nullable which is true if the database supports the
concept of a NULL column.

2) Require the interface to translate None into the appropriate
false-equivalent data values, i.e. None to '', 0, 0.0, 0L as appropriate,
upon writing to the database. No translation would be required on reading.

3) Both of these.

Whether or not we should try to slide it into the 2.0 spec is another
matter; a little late, perhaps, to be thinking of this, and may fixing
something that ain't broke. At least on databases which support NULL
columns, the worst that would have to be done is to add nullable = 1. For
those not supporting NULL (I suspect virtually all SQL databases support
it), it might be difficult to know in advance what the correct data type
should be for writing.

-- 
andy dustman  | programmer/analyst |  comstar communications corporation
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d