我使用dbf 0.95.004,我需要从表格中选择一个字段。 Example,docs
import dbf
table = dbf.Table('my.dbf').open()
records = table.sql('select name')
但是我有错误:
AttributeError: 'Db3Table' object has no attribute 'sql'
我打开dbf.py并找到
def pql(records, command):
不是def sql(records, command):
中的docs。
当然,我可以在没有sql的情况下这样做:
for record in table:
record['name']
但是我需要使用sql-select。那么,如何解决呢?
dbf.pql(table, 'blah blah')
(之所以这样命名,因为它是一种非常类似于sql的语法),也可以使用table.query()
。这些不是开发完善的例程,因为我发现使用常规Python语法更容易。