table is a table object and not a string... here's an example. creating the table is easy enough, but referencing is different...
# VARS tlist = ['martP4Sync', 'coreP4Sync', 'testP4Sync'] # MAKE TABLES for t in tlist: db.define_table('{0}'.format(t), Field('name'), Field('value')) db.commit() # DO STUFF (insert, update, select,....) for pTable in db.tables: if 'P4Sync' in pTable: if pTable.startswith('martP4'): db(db[pTable].insert(name='myname1',value='myvalue1')) db(db[pTable].insert(name='myname2',value='myvalue2')) db.commit() Hope it helps, Mart :) On Dec 1, 7:30 pm, Branko Vukelic <bg.bra...@gmail.com> wrote: > On Thu, Dec 2, 2010 at 1:23 AM, Stef Mientki <stef.mien...@gmail.com> wrote: > > that doesn't return a table variable, but a string, > > so maybe you want > > return eval ( 'db4' + 'arraydata_table') > > Don't use eval. It's evil! :) > > 'db4' doesn't have to be a string. I think you can access the tables > using subscript notation: > > db4['tablename'] > > Here's the code I posted earlier with modifications: > > def table_builder(e, p): > if e == 'inverter': > if p == 0: > t = 'arraydata_table' > elif p == 1: > t = 'array_mins' > else: > t = '%smins' % period > return db4[t] > > -- > Branko Vukelić > > bg.bra...@gmail.com > stu...@brankovukelic.com > > Check out my blog:http://www.brankovukelic.com/ > Check out my portfolio:http://www.flickr.com/photos/foxbunny/ > Registered Linux user #438078 (http://counter.li.org/) > I hang out on identi.ca:http://identi.ca/foxbunny > > Gimp Brushmakers Guildhttp://bit.ly/gbg-group