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"] = "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?

I've downloaded dbfpy and experimented with it and I've found that
opening the file with file(fpath,"ab+") causes some extra junk to be
appended to the end of the file when the DBF file is closed. It works
much better (and is simpler!) if you open the DBF file with the
filename:

fpath = os.path.join(local.DB_DIR, "partners.dbf")
tbl = dbf.Dbf(fpath)
rec = tbl.newRecord()
rec["FIELDNAME1"] = 1
rec["FIELDNAME2"] = "Somebody"
rec.store()
tbl.close()
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to