One further option is to run the code as a script via the command line:
python web2py.py -S myapp -M -R myscript.py
That will run myscript.py in the environment of myapp (including the
models). This approach doesn't put code into the app that only gets
executed one time in the life of the app.
another way around is i think you can define it on controllers, let say it
initialize.py, and put the insert db or populate in there, so when you want
to initialize insert db, just access the controller, after all db is
initalized you can either comment all the script or remove it. it seems
lik
I used a similar approach, in my appconfig.ini after pool_size i added
first_run = True and wrapped every sentence i want to run only one time
with if (myconf.take('db.first_run') == 'True'):
Thanks for the help!
El martes, 4 de agosto de 2015, 9:55:22 (UTC-4:30), Lisandro escribió:
>
> The way
The way I do it is this: I define a module and I define in there a function
that does db initialization.
modules/myfunctions.py
# -*- coding: utf-8 -*-
from gluon import *
def initialize_db():
db = current.db
# here, do all needed inserts to database tables
Then, in db.py (after tabl
4 matches
Mail list logo