dbfpy - cannot store new record

David Lyon david.lyon at preisshare.net
Thu May 21 10:07:19 EDT 2009


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 <gandalf at shopzeus.com>
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"] = "Somebody"
> rec.store()
> tbl.close()
> 
> I get no exception, no error etc. But the new record is NOT appended to 
> the table. What is wrong here?
> 
> Thanks,
> 
>    Laszlo



More information about the Python-list mailing list