At the moment to pre-populate a database, I place this in the db.py model 
file:

db.define_table('color',
    Field('name','string'),
    Field('code','string'),
    format='%(name)s')
if db(db.color).isempty():
    # create instance of table
    for k,v in 
dict(lime="#00FF00",red="#FF0000",black="#000000",orange="#FFA500",\
        blue="#0000FF", yellow="#FFFF00", fuchsia="#FF00FF", 
aqua="#00FFFF",\
        maroon="#800000", green="#008000", navy="#000080", olive="#808000",\
        purple="#800080", teal="#008080", gray="#808080", 
silver="#C0C0C0").items():
        db.color.insert(name=k,code=v)



I wonder if this is the best way to pre-populate a database?

thanks,
Ben

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to