For each table you have in MySQL db, you need to define the model (usually
in db.py)

db.define('table',Field('field1'),Field('field2'),migrate=False)

note "migrate=False" because you already have db created outside web2py.

If you want to extract the model from the existing db, you can use
http://code.google.com/p/web2py/source/browse/scripts/extract_mysql_models.py

If you have a new database, the better is to define the tables in web2py
models ( web2py will create the tables 4 you)

But if you need to use an existing database, the solution is here
http://web2py.com/book/default/chapter/06#Legacy-Databases-and-Keyed-Tables

2010/11/11 noPE <soumyama...@gmail.com>

> I have create a database 'new' for one of my applicaiton. And also
> added some tables and records to it via the administrative interface.
> I can see it on mysql client. But when i start the web2py shell on my
> terminal and do
> this :
> db = DAL('mysql://user:passw...@localhost/new')
>
> and do
> >> print db.tables
> >> []
>
>
> It gives me an empty list. But when i check the database from my myqsl
> client it shows the tables. Also i am able to use those tables for my
> app, via my browser in http:localhost:8000/new.
>
> What is the problem. Somebody help.
>
> Regards
> soumya




-- 

http://rochacbruno.com.br

Reply via email to