I use dbf 0.95.004, I need to select one field from table. Example, docs

import dbf
table = dbf.Table('my.dbf').open()
records = table.sql('select name')

But I have error:

AttributeError: 'Db3Table' object has no attribute 'sql'

I open dbf.py and find

def pql(records, command):

Not def sql(records, command): like in the docs.

Ofcourse, I can do like this without sql:

for record in table:
    record['name']

But I need to use sql-select. So, how to fix it?

有帮助吗?

解决方案

My apologies (x2), the docs are way out of date. You can either use dbf.pql(table, 'blah blah') (named that way because it is a very limited sql-like syntax), or table.query(). These are not well developed routines as I found using normal Python syntax easier.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top