The problem is not so much creating them but keeping track of them. Here is a possible solution:
# a table of tables db.define_table('meta_table',Field('name'),Field('fields','json')) # for each table in meta_table define or create the table: for table db(db.meta_table).select(): db.define_table(table.name,**[Field(item['name']) for item in table.fields]) # make an action to populate the meta_table: def create_table(): form = SQLFORM.factory(Field('name'),Field('fields','list:string')) if form.process().accepted: db.meta_table.insert(name=form.vars.name,fields=[{'name':name} for name in form.vars.fields]) redirect(URL('somewhere')) return dict(form=form) This assumes all fields are string but you can easily change that. ;-) On Friday, 27 June 2014 04:25:10 UTC-5, Shubham Jain wrote: > > I want to create a database table every time a form is submitted. The > table name would be a data from a the field of form submitted. > I tried to create the table by writing the db.define_table(....) code in > the function in which the form is created (by SQLFORM), under the condition > if form.process().accepted: > But in this the form is getting submitted but table is not created. Please > help me over this ? > -- 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.