Newbie question: how to include existing tables in the model

1 view
Skip to first unread message

Ernesto Savoretti

unread,
Aug 16, 2008, 10:42:51 PM8/16/08
to web2py Web Framework
Sorry for asking something that surely has an obvious answer, but
being a newbie in web2py, I'm having trouble in using existing
database tables. If I don't include them in the model by
"db.define_table(...)", I can't use them at all. If I do, I get an
error message stating: "table already exists".
Any workaround would be highly appreciated.

voltron

unread,
Aug 17, 2008, 1:52:52 AM8/17/08
to web2py Web Framework
If the table exists, you have to set the "migrate" value to false,
here is an example:

db.define_table('users',
SQLField('user_name' , 'string', length = 255, required =
True, unique = True),
SQLField('password' , 'password', length = 128),
SQLField('email' , 'string', length=255, required =
True, unique = True),
migrate = False
)

Ernesto Savoretti

unread,
Aug 17, 2008, 11:03:28 AM8/17/08
to web2py Web Framework


On Aug 17, 2:52 am, voltron <nhy...@googlemail.com> wrote:
> If the table exists, you have to set the "migrate" value to false,
> here is an example:
>
> ....

That does it. Thanks a lot.
Reply all
Reply to author
Forward
0 new messages