Re: dbfpy - cannot store new record

2009-05-27 Thread Ethan Furman
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 F

Re: dbfpy - cannot store new record

2009-05-22 Thread John Machin
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

Re: dbfpy - cannot store new record

2009-05-22 Thread Laszlo Nagy
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 i

Re: dbfpy - cannot store new record

2009-05-21 Thread David Lyon
On Fri, 22 May 2009 08:34:17 +0200, Laszlo Nagy wrote: > 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 invali

Re: dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
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["SOMEFIELD

Re: dbfpy - cannot store new record

2009-05-21 Thread John Machin
On May 22, 1:53 am, 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["SOM

Re: dbfpy - cannot store new record

2009-05-21 Thread David Lyon
well, dbfpy isn't super sophisticated. If you make your own code fixes, maybe you can provide them back to the package author. On Thu, 21 May 2009 17:53:38 +0200, Laszlo Nagy wrote: > Here is the next problem. For boolean/logical fields, I can set their > value to True/False easily. However,

Re: dbfpy - cannot store new record

2009-05-21 Thread MRAB
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 F

Re: dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
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

Re: dbfpy - cannot store new record

2009-05-21 Thread MRAB
Laszlo Nagy wrote: [snip] I have never seen such a construct before. Index a tuple with a boolean??? self.stream = file(f, ("r+b", "rb")[bool(readOnly)]) Python originally didn't have Boolean; it used 0 for false and 1 for true. When the Boolean class was added it was subclasse

Re: dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
David Lyon írta: Hi, Try not opening the file in append mode (no "a+") Inside the logic, there is already a seek to the end of the file and the record counters at the start of the file need updating too. The first thing I tried is to use a filename instead of the file object but it didn't w

Re: dbfpy - cannot store new record

2009-05-21 Thread David Lyon
Hi, Try not opening the file in append mode (no "a+") Inside the logic, there is already a seek to the end of the file and the record counters at the start of the file need updating too. Regards David On Thu, 21 May 2009 13:25:04 +0200, Laszlo Nagy wrote: > Given this example program: > >

Re: dbfpy - cannot store new record

2009-05-21 Thread MRAB
Laszlo Nagy wrote: Given this example program: import dbfpy def dbf_open(tblname): fpath = os.path.join(local.DB_DIR,tblname) f = file(fpath,"ab+") f.seek(0) tbl = dbf.Dbf(f) return tbl tbl = dbf_open("partners.dbf") rec = tbl.newRecord() rec["FIELDNAME1"] = 1 rec["FIELDNAME2"] =

dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
Given this example program: import dbfpy def dbf_open(tblname): fpath = os.path.join(local.DB_DIR,tblname) f = file(fpath,"ab+") f.seek(0) tbl = dbf.Dbf(f) return tbl tbl = dbf_open("partners.dbf") rec = tbl.newRecord() rec["FIELDNAME1"] = 1 rec["FIELDNAME2"] = "Somebody" rec.stor