Now I understand.
I think this should work:
# some loop over name,repoType,task
db.define_table("{0}{1}{2}".format(name,repoType,task),
Field('fileName'),
Field('fileSize','integer'))
for pTable in db.tables:
if 'P4Sync' in pTable:
if pTable.startswith('coreP4'):
db(db[pTable].id > 0) blablablabla ....
On Nov 22, 12:51 am, mart <[email protected]> wrote:
> oh, sorry...
>
> So, for every individual sync (or pull) action from any given
> repository, i want to log which file was synced, its size, its
> revision number, changelist (or changeset) number, the src/dest
> mapping, etc... So, I would like the automation to create one table
> per sync task (or any other source control task). I would like the
> automation to name the table following a defined naming convention (so
> that it could go back and insert/update later in the process).
>
> Given that, "if 'P4Sync' in pTable:" means 'do any of my tables have
> "P4Sync" in their name?', if yes, then the automaton can collect their
> names, then process them one at a time (I.e. for reporting purposes,
> get full history of filesets being diffed, etc...)... Ya, I know I go
> over board with this type of stuff, but can't help it... I like to
> produce as much detail as possible with the clearest of structure
> (intuitive) when folks look at it (or when I have to look at it)
>
> Thanks and hope its clearer,
> Mart :)
>
> On Nov 22, 12:55 am, mdipierro <[email protected]> wrote:
>
> > This line
>
> > if 'P4Sync' in pTable:
>
> > will never work. What is it supposed to do?
>
> > On Nov 21, 10:39 pm, mart <[email protected]> wrote:
>
> > > Hi,
>
> > > I need to create some tables dynamically (SQLite). Creating them is
> > > fine, but when comes time to use, well that just isn't working...
>
> > > I'm doing this to for some automation where I don't know in advance
> > > how many tables will be created or even what they will be called...
>
> > > I tried a few things, but i don't think we can use variables when
> > > referencing tables?
>
> > > For example, if I do something simple like:
>
> > > lets say I'm looking for tables that contain sync logs, where the
> > > dynamically created table name would be named using a defined
> > > structure like <name>P4<taskName> (i.e. coreP4sync).
>
> > > I can do :
>
> > > define_table("{0}{1}{2}".format(name,repoType,task),
> > > Field('fileName'),
> > > Field('fileSize','integer'))
>
> > > So, I may end up any number of of these tables. How can I simply look
> > > up the table names, see if any of them match the pattern, then do
> > > stuff accordingly?
>
> > > seems that something like below would never work?: Is there a work
> > > around?
>
> > > for pTable in db.tables:
> > > if 'P4Sync' in pTable:
> > > if string.split(pTable,'P4')[0] == 'core':
> > > db(db.pTable.id > 0) blablablabla ....
>
> > > Thanks,
> > > Mart :)
>
>