使用Python编写带有fpt备忘录的dbf表



我有一个使用.dbf和.fpt文件的遗留应用程序。我想读和写这些文件,我已经找到了一种方法来写这些文件,但不使用fpt备忘录。我使用python 2.7.2和dbf模块0.95.02。当我尝试使用dbf模块时,我在尝试使用FpTable时得到一个错误。

>>> import dbf
>>> table = dbf.FpTable('test','name C(25); age N(3,0); qualified M')
>>> table
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4428, in __repr__
    return __name__ + ".Table(%r, status=%r)" % (self._meta.filename, self._meta.status)
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4213, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Db3Table' object has no attribute '_meta'
>>> table.open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4953, in open
    meta = self._meta
  File "/Users/doctor/.virtualenvs/dbf/lib/python2.7/site-packages/dbf.py", line 4213, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Db3Table

我希望创建一个读取和写入dbf文件与fpt备忘录。能够创建.cdx索引文件将是一个理想的选择。我愿意以任何方式做上述任何一件事。

简短的回答是不要直接使用FpTable。你应该可以,但我从来没有真正尝试过,因为我总是使用Table(name, fields, dbf_type='fp')

谢谢你的bug报告。div;)

最新更新