dbfpy - cannot store new record

Laszlo Nagy gandalf at shopzeus.com
Fri May 22 08:34:17 CEST 2009


>> 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
>> rec.store()
>>
>> 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.
>>     
>
> That's not "invalid", it *is* "NULL" according to DBF convention.
>   
Now I also tried to set -1. In any of the above cases, if I open that 
dbf file with a commercial DBF editor application then I see that the 
value is not null.

- Borland Database Desktop shows "False" value
- CDBF shows an invalid value, noted with a question mark (screenshot 
attached)

Best,

   Laszlo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not_null_not_false.GIF
Type: image/gif
Size: 7610 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090522/4c54dc5d/attachment.gif>


More information about the Python-list mailing list