On 4 February 2018 at 07:43, Massimo Di Pierro
<[email protected]> wrote:
> How does it compare with this?
>
> https://github.com/web2py/web2py/blob/master/scripts/extract_pgsql_models.py
>
>
> If better, can you merge and make a PR?
Thanks Massimo. I did not know (or forgot) about that script.
I have tested it now.
I will not try and merge the two scripts. I think the two scripts
serve different purposes.
The one you mentioned was not able to create models from one of my
bigger databases because of problems with types:
Traceback (most recent call last):
File "/home/js/web2py/scripts/extract_pgsql_models.py", line 286, in <module>
define_db(cnn, db, host, port, user, passwd)
File "/home/js/web2py/scripts/extract_pgsql_models.py", line 270, in define_db
define_table(conn, table)
File "/home/js/web2py/scripts/extract_pgsql_models.py", line 248, in
define_table
fdef = define_field(conn, table, field, pks)
File "/home/js/web2py/scripts/extract_pgsql_models.py", line 132, in
define_field
raise RuntimeError("Data Type not supported: %s " % str(field))
RuntimeError: Data Type not supported: {'data_type': 'timestamp with
time zone', 'numeric_precision_radix': None, 'is_nullable': 'YES',
'character_maximum_length': None, 'column_default': None,
'numeric_precision': None, 'numeric_scale': None, 'column_name':
'last_login'}
Mine was designed to create legacy tables' models leaving out
particulars like field length and primary keys
which the database handles. Also my script is able to handle
collisions between field (and table) names with the
reserved words in web2py and PostgreSQL-types like uuid, citext, a
boolean that is not a character type and tsvectors.
I have for example a database with many schemas and hundreds of
tables. I will only use web2py for one schema.
I use web2py mostly as a web interface to existing databases and
minimize my use of DAL. I prefer direct SQL.
DAL is useful for interactions with forms and grids. But to
manipulate and select data I mostly use executesql.
Regards
Johann
--
Because experiencing your loyal love is better than life itself,
my lips will praise you. (Psalm 63:3)
--
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 the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.