dbfpy - cannot store new record

John Machin sjmachin at lexicon.net
Fri May 22 19:02:15 EDT 2009


On 23/05/2009 12:32 AM, Laszlo Nagy wrote:
> 
>> dbfpy is very old code.....
>>
>> Try setting up a CHAR(1) field and filling it with "Y" or "N" or
>> "T" or "F".. indicating yes,no,true or false...
>>   
> Unfortunately, my task is to import records into a database that is used 
> by an old foxpro program. I'm not allowed to change the database 
> structure in any way.

It would have helped if you'd mentioned "foxpro" in your first message 
... [Q1] Is that really merely "Foxpro" or is it actually "Visual 
Foxpro" aka "VFP"? What version?

And some more questions:
[Q2] What (in hex, please) is in the first byte of the existing "old 
foxpro" DBF files that you need to update?
[Q3] Do you see the string "_NullFlags" in the first 1000 or so bytes of 
  those DBF files?
[Q4] What makes you sure that the "old foxpro program" can handle NULLs 
in L (logical) fields?
[Q5] How are NULLs represented in L (logical) fields in those files:
    (a) "?"
    (b) " "
    (c) weird stuff (see Q3)
    (d) something else
[Q6] Are there any FPT files in the same folder as the DBF files?
[Q7] Are there any CDX or MDX (or other ??X) files in the same folder as 
the DBF files?

>> otherwise... just debug the dbfpy code...
>>   
> This is what I'll do. Thanks.

Debugging something usually implies that the debugger knows what is 
expected behaviour :-)

In any case, what's to debug? The dbf code says rather plainly that it's 
set up for an (a) answer to Q5:
''' from fields.py line 311 onwards:
     def encodeValue(self, value):
         """Return a character from the "TF?" set.

         Return:
             Return value is "T" if ``value`` is True
             "?" if value is -1 or False otherwise.

         """
         if value is True:
             return "T"
         if value == -1:
             return "?"
         return "F"
'''

Cheers,
John



More information about the Python-list mailing list