we also have scripts/extract_mysql_models.py
Massimo On Oct 3, 5:37 pm, Alexandre Andrade <[email protected]> wrote: > Alvaro, > > I didn't see this post before. > > this can be a great feature and I will trye to adapt it to postgresql and > mysql, at least. > > if massimo already don't use it, with sqlite, postresql and mysql, it can > worth the value. > > 2010/6/11 Álvaro Justen <[email protected]> > > > > > Hello Alexandre, nice work. > > I did it in past for SQLite and made it integrated to DAL > > I think we can union the implementations and try to get more databases > > working with this code. > > > 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 > > -- > Atenciosamente > > -- > ========================= > Alexandre Andrade > Hipercenter.com

