Oleg...
Thanks for this....
I tried your method, but I think you can't dynamically create classes that
way. I had some success with this:
table_classes = []
i = 0
for table in tables:
print i, "-", table[0]
y = new.classobj('sqlmeta', (), {'table': table[0], 'fromDatabase':
True})
x = new.classobj(str(table[0]),(SQLObject,), {'sqlmeta': y})
for z in x.sqlmeta.asDict():
print z
table_classes.append(x)
i += 1
But it's still not completely right....I get this error:
Traceback (most recent call last):
File "samdump.py", line 32, in <module>
for z in x.sqlmeta.asDict():
TypeError: unbound method asDict() must be called with sqlmeta instance as
first argument (got nothing instead)
Anyone know what I'm doing wrong? I sort of guessed at how to do it...if
you can't tell. :)
Thanks!
On Sun, Apr 13, 2008 at 12:27 PM, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
> 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/ [EMAIL PROTECTED]
> 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@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
-------------------------------------------------------------------------
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss