if you set migrate=True web2py does the check for you and eventually
creates tables. It can only detect tables if they were created by
web2py itself since it uses metadata for that purpose.

On Jun 11, 7:25 am, mika <miss.from.h...@gmail.com> wrote:
> hi i would like to make my application generate database at startup
> (sth like first run) - i mean generating automatically all needed
> relations (hardcoded)..
> on startup i would like to check if database was prepared before
>
> How to achieve this? what to do with migration?
> i though about such code (doesn't work) in db.py
>
> if 'places' in db.tables: #that means db was created before
>     print "Loading Database..."
>     GLOBAL_MIGRATE=False #tables already exists
> else:
>     print "This is first run, database is not prepared! Generating
> it..." # create tables
>     GLOBAL_MIGRATE=True
>     #and below put all necessary data to tables
>
> i use GLOBAL_MIGRATE to set migrate on all tables.

Reply via email to