Re: [SQLObject] Finding the names of the tables...

Top Page
Author: Oleg Broytmann
Date:  
To: sqlobject-discuss
Subject: Re: [SQLObject] Finding the names of the tables...
On Sat, Apr 12, 2008 at 07:31:07PM -0300, Sam's Lists wrote:
> So you've given me step one and it works well. Thank you.
>
> tables = connection.queryAll('show tables')
> for table in tables:
> print "\t", table[0]
>
> Now I know step three is something like this:
> recdict = record.sqlmeta.asDict()
>
> But I can't figure out how to go from step one to step three. Given the
> table name as a string, how do I convert it to an object where sqlobject
> goes and creates an object based on the info in the database?


   Something like this:

tableClasses = {}
for table in tables:
    tname = table[0]
    class Table(SQLObject):
        class sqlmeta:
            table = tname
            fromDatabase = True
    tableClasses[tname] = Table

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd@???
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@???
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss