Re: [web2py] how may I get programmatically postgres field type from web2py model definition?

2015-02-06 Thread Richard Vézina
I work around that by just print string of db.table.field.type and write my model in web2py then generate SQL with an SQL generator app... :) This will be all right, I am not writing SQL that much anymore, I let web2py generate it form me :) Richard On Fri, Feb 6, 2015 at 9:23 AM, Richard Vézin

Re: [web2py] how may I get programmatically postgres field type from web2py model definition?

2015-02-06 Thread Richard Vézina
Hoho! As you mention Anthony, db._adapter.types[] doesn't provide the direct backend type... You get the type but not the extend of the domain of the field... Also, notice that in case of web2py decimal db.table.field.type will be 'decimal(4, 2)' and the key in _adapter.types is only 'decimal' whi

Re: [web2py] how may I get programmatically postgres field type from web2py model definition?

2015-02-06 Thread Richard Vézina
Hello Leonel, Actually my tables names are prefixed with old postgres schema name so, I can easily filter the one of interest... Also, the IDs fields don't matter, since the are prefixed with table name like so "tablename_id"... I also change some fields names that are common in many table like "

Re: [web2py] how may I get programmatically postgres field type from web2py model definition?

2015-02-06 Thread Richard Vézina
Yes!! That what I thought... I had already db.table.field.type in mind, but didn't know how to invoque adapter... Thanks Anthony. Richard On Fri, Feb 6, 2015 at 7:55 AM, Anthony wrote: > And if you want the actual Postgres field type for a given field, you can > do: > > db._adapter.types[db.t

Re: [web2py] how may I get programmatically postgres field type from web2py model definition?

2015-02-06 Thread Anthony
And if you want the actual Postgres field type for a given field, you can do: db._adapter.types[db.tablename.fieldname.type] However, you will get back values that include Python string formatting syntax, such as: VARCHAR(%(length)s) Anthony On Friday, February 6, 2015 at 4:55:31 AM UTC-5,

Re: [web2py] how may I get programmatically postgres field type from web2py model definition?

2015-02-06 Thread Leonel Câmara
Do you want a list of all field types? This would do it: field_types = [] for table in db.tables: for field in db[table].fields: field_types.append(db[table][field].type) However you will have a lot of ids. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation)

[web2py] how may I get programmatically postgres field type from web2py model definition?

2015-02-05 Thread Richard
Hello, I am in the process of refactoring model definition and merging multiple table into one table with multiple columns (denormalisation) and I would like to extract programmatically the time of each of the multiple tables fields... Thanks Richard -- Resources: - http://web2py.com - http

[web2py] model definition

2010-11-18 Thread Richard Vézina
Hello, I would clarify my understanding a bit... In the book it says : Notice that requires=... is enforced at the level of forms, required=True is enforced at the level of the DAL (insert), while notnull, unique and ondeleteare enforced at the level of the database. While they sometimes may seem