Actually, what I posted above is crap! ;)

easier just to do something like this:


gloss = {<build_version> :
c8b669d15150d7109e5f7ab36744a5b7_changes.table}
myTable = getTable(gloss[build_version])


def getTable(tbl):
    for tblName in db.tables:
        if tblName.startswith(tbl):
            return tblName


alright, time for caffeine :)


On Feb 2, 11:46 pm, mart <[email protected]> wrote:
> Hi, yeah, been thinking abou that one... creating the tables is a good
> idea, the trick is to keep them identifiable for the consumers of this
> info... from one churn of the automation to the next, all tables are
> the same in name and appearance. So I was thinking, perhaps we can
> trick the user (wo will want to search by build_version number, by
> forcing their query to resolve that version number to the tables' long
> md5-ish name. So, thinking about a glossary (really a dictionary). I
> haven't yet tried it but, something like this should return the
> tableName to a user using the build_number instead of the table
> name...
>
> glossary_changes = {<build_version> :
> c8b669d15150d7109e5f7ab36744a5b7_changes.table}
>
> ...assume tableName is 'changes'
>
>     resolvedTableName = getTable(myBuildPath, table2Query,
> myBuildVersion)
>
>     def table_exists(folderPath,tableName):
>         try:
>             tableName = os.path.join(folderPath,
>                                     '{0}
> _{1}.table'.format(md5_hash(self.db._uri),tableName))
>             return False
>         except:
>             return False
>
>     def getTable(folderPath, table2Query, ver):
>         gloss = 'glossary_{0}'.format(table2Query)
>         tables = gloss.keys()
>         for mTbl in db.tables:
>             for tbl in tables:
>                 if mTbl.startswith(tbl):
>                     for row in
> db(db[mTbl].buildVersion==ver).select():
>                         if table_exists(folderPath, row.tableName) is
> True:
>                              return row.tableName
>
> should return ==> c8b669d15150d7109e5f7ab36744a5b7_changes.table
>
> Thanks for your input!
>
> Mart :)
>
> On Feb 2, 5:21 pm, howesc <[email protected]> wrote:
>
>
>
>
>
>
>
> > i don't know sqlite.  never really used it so i can't say much about that.
>
> > can you take your file paths and use that to prefix the table names?  there
> > is nothing stopping you from creating the table name dynamically and
> > accessing using db['table name string'].

Reply via email to