Dal Field Types

79 views
Skip to first unread message

Daniel Lafrance

unread,
Mar 3, 2016, 2:23:54 AM3/3/16
to web2py-users
Hi group

I am trying to build a db dynamic app but I am stick on the following problem.

I am able to get the filenames of a table by the syntax ;

fields = list(db.resultats.keys())

But I am unable to find how to get the field types. Is there a special syntax that i could use ?

Something like ...:

ftypes = list(db.resultats.field_types())

Regards !

Anthony

unread,
Mar 3, 2016, 10:04:27 AM3/3/16
to web2py-users
field_names = db.resultats.fields
field_types
= [f.type for f in db.resultats]

Anthony

Mirek Zvolský

unread,
Mar 4, 2016, 2:47:36 AM3/4/16
to web2py-users
just detail: db.resultats._fields



Dne čtvrtek 3. března 2016 16:04:27 UTC+1 Anthony napsal(a):

Anthony

unread,
Mar 4, 2016, 6:12:25 AM3/4/16
to web2py-users
On Friday, March 4, 2016 at 2:47:36 AM UTC-5, Mirek Zvolský wrote:
just detail: db.resultats._fields

There is no need to use db.resultats._fields, as db.resultats.fields is a Python property that simply returns db.resultats._fields.

Also, it is a SQLCallableList, so db.resultats.fields() returns a copy of the original list, meaning you can mutate it without affecting the original list.

Anthony

Mirek Zvolsky

unread,
Mar 8, 2016, 6:48:30 AM3/8/16
to web...@googlegroups.com
I'm sorry, didn't know this.
My (bad) idea was that all without underscore is reserved for db.table.fieldname.
Now I see that there are additional names which I should avoid as field names, like "fields", "keys", "sqlsafe". Correct?


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/p608VqzV2GM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Daniel Lafrance

unread,
Mar 13, 2016, 11:53:00 AM3/13/16
to web2py-users
Thanks Guys
Reply all
Reply to author
Forward
0 new messages