ZekeDroid
ZekeDroid

Reputation: 7209

Extracting field names from web2py db query in order

Even though the SQLTABLE method displays the table I was looking for, I must manually create such a table for other purposes (must make each field turn into input box on click and then do an update on the db). Because of this I am looking at extracting information manually.

How do I extract the field names as defined by the returned Rows?

My first try was to do:

db(db.tableName).select().first().keys()

However, this will return the keys in whatever order they were hashed in which is not the order that the Fields are actually in in the db. What's the correct way of extracting this info?

Upvotes: 1

Views: 490

Answers (1)

Anthony
Anthony

Reputation: 25536

The field names for a table are stored in db.tablename.fields, in the order the fields are defined in the model.

Upvotes: 1

Related Questions