SQLObject
??
Jonhy
Nice! This is super excellent.
The email I sent to Massimo talking about my work (in the end of 2009)
is copied and my code is attached:
Note: I think we should discuss it in web2py-dev list.
----------------------
Hi Massimo,
Some weeks ago I had an idea: db.discover_tables() - a function that
will search DB and map it into web2py's DAL.
Today a user asked about it in mail list, so I decided to try: and my
first result is good, I think.
My implementation only have support to SQLite, but we can add all
databases with a little effort - I think you could help me in this
task.
I modified that simple 'news' app an gluon/sql.py. My modification is
NOT based on SVN, it is based in 1.62 rc1.
To test: modify db.py, uncomment define_table and comment
discover_tables. So, web2py will create tables. Enter in appadmin and
populate them. After that, comment all define_table and uncomment
discover_tables. So, enter in:
http://localhost:8000/news/appadmin/select/db?query=db.authors.id%3E0
http://localhost:8000/news/appadmin/select/db?query=db.news.id%3E0
http://localhost:8000/news/default/test
http://localhost:8000/news/default/create_code
In gluon/sql.py I added:
- method discover_tables in class SQLDB.
- some code in __init__ in class SQLDB.
- keys 'show_tables' and 'table_fields' in SQL_DIALECTS['sqlite'] ->
please add keys to other databases and test if you could.
I'm sure that this code can be optimized.
What do you think?
--
Álvaro Justen - Turicas
http://blog.justen.eng.br/
21 9898-0141
Please post news about this. :-)
--
Álvaro Justen - @turicas
http://blog.justen.eng.br/
21 9898-0141