0

I'm trying to update a field in a *.dbf file.

For this I have created a function inspired from Search in DBF and update record.

My function look like this:

def read_one_db_fox_record(database, collName, colMatch):
    path = 'c://'
    db = dbf.Table(path +database+'.dbf')
    db = db.open(mode=dbf.READ_WRITE)

    with db:

        x = lambda rec,col=collName: (rec.col)
        #Problem is somewhere here

        procod_idx = db.create_index(x)
        match = procod_idx.search(match=(colMatch))
        record = match[0]
        logging.debug(record)
        db.close()

Call:

read_one_db_fox_record('db', 'keye', '1')

Output:

raise FieldMissingError(name)
FieldMissingError: 'col:  no such field in table'

Why lamba is not passing collName value to col? I was expecting lambda to call rec.keye.

Dragos Vasile
  • 453
  • 4
  • 12

0 Answers0