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

Andy Dustman adustman@comstar.net
Wed, 14 Apr 1999 13:24:02 -0400 (EDT)


On Wed, 14 Apr 1999, M.-A. Lemburg wrote:

> 	  SQL NULL values are represented by the Python
> 	  None singleton on input and output.

This is no problem.

> and/or add an aliase NULL for None that the module has to define.

You know, I might actually do something like this in MySQLdb. On reading
from the database, NULLs are returned as Py_None (None). On writing to the
databse, a NULL value has to be specified as the token NULL. Part of what
I did to pull this off involves defining a string in the _mysql module
(the C level), i.e. NULL='NULL'. From an application perspective, however,
this None to NULL translation happens transparently (is performed by the
Python level); the application reads and writes None to reprsent a NULL
value.

From an interface perspective, however, I think we should require the
above behavior you propose inserting. It is the de facto standard way of
doing things, and I think we just overlooked it's abscense, since NULL
<--> None is such a natural mapping. NULL should probably not be part of
the specification, since if it is, someone will become dependent on it and
most interfaces won't have it.

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