dbfpy - cannot store new record
ethan at stoneleaf.us
Wed May 27 16:55:12 CEST 2009
Laszlo Nagy wrote:
> Here is the next problem. For boolean/logical fields, I can set their
> value to True/False easily. However, setting NULL seems impossible:
> rec = tbl.newRecord()
> rec["SOMEFIELD1"] = True # Works fine
> rec["SOMEFIELD2"] = False # Works fine
> rec["SOMEFIELD3"] = None # Will store False
> rec["SOMEFIELD3"] = 0 # Will store False
> rec["SOMEFIELD3"] = "" # Will store False
> rec["SOMEFIELD3"] = chr(32) # Will store False
> rec["SOMEFIELD3"] = chr(0) # Will store False
> Strange thing: if I do not set the value of a numeric field, it becomes
> NULL. The same thing I cannot do for logical fields: if I do not set the
> value of a logical field, it becomes an invalid value, denoted with a
> question mark.
> Any ideas?
Not sure if this would help, but you might try
At this point, the only data types allowed to be Null are dates and
times, everything else is coerced to Pythons idea of nothing if not set
(strings are '', numerics are 0, etc -- again, the only exception being
dates and times which, IIRC, default to the moment of record creation).
Hope this helps.
More information about the Python-list