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

时间:2013-05-22 02:22:32

标签: python dbf dbase xbase

我有一个使用.dbf和.fpt文件的遗留应用程序。我正在寻找和编写这些文件,我已经找到了编写这些文件但不使用fpt备忘录的方法。我使用的是python 2.7.2和dbf模块0.95.02。当我尝试使用dbf module时,我在尝试使用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

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

1 个答案:

答案 0 :(得分:0)

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

感谢您提供回合错误报告。 ;)

相关问题