Note that everything (in models, controllers, and views) is python code so you can check first then add if not there:
if not db(db.auth_group).select(): db.auth_group.insert(role = "Admin", description = "Admin") or more specifically: if not db(db.auth_group.role=='Admin').select(): db.auth_group.insert(role = "Admin", description = "Admin") On Apr 14, 12:36 pm, Stifan Kristi <[email protected]> wrote: > hi, anthony, > > thank you so much for your detail explaination, right now, i use appadmin, i > think there is another way to put it on a code like on sql script. > > best regards, > > steve van christie > > > > > > > > On Thu, Apr 14, 2011 at 11:33 PM, Anthony <[email protected]> wrote: > > Your model files are run on every request, so you shouldn't put any > > one-time code in a model file. The easiest way to do this would be manually > > via appadmin (see > >http://web2py.com/book/default/chapter/03#More-on-appadmin). You could > > also do it from a web2py shell or by putting the code in a Python script > > file and executing the file with web2py command line options (see > >http://web2py.com/book/default/chapter/04#Command-Line-Options, in > > particular, the -S and -R options). > > > Anthony > > > On Thursday, April 14, 2011 11:54:17 AM UTC-4, 黄祥 wrote: > > >> hi, > > >> is there possible to insert the data auth_group during database > >> creation for the first time? > >> e.g. > >> db.auth_group.insert(role = "Admin", description = "Admin") > > >> i've already tried to put it on models but, the data inserted is > >> repeated many times. > > >> any idea, suggestion or correction? > > >> thanks and best regards, > > >> steve van christie

