Hi All,
I'm building a tool to extract info from databases. The
user/programmer doesn't have any advance knowledge of the structure of
the database before they load it, and i want to dynamically generate
mapped classes for the database.
i just want to check there isn't some helpful sqlalchemy stuff that
can make my life easier, cos it feels harder than it should be.
sqlsoup seems to expect you to know table names ahead of time. i can't
find a way of extracting a list of table names from db =
SqlSoup(engine) and i'm finding myself generating classes on the fly
using the type() function.
stuff like:
meta.reflect(bind=engine)
tables = meta.raw_tables
class MyTable(object):
pass
for t in tables:
tempclass = type('Table%d'%counter,(MyTable,),{'engine':self.engine})
mapper(tempclass,t)
then i use a bunch of classfunctions hanging off MyTable to do things
like return select alls ... anyways, this feels harder than it should
be. am i missing something? or is sqlalchemy simply not really used
much to work with existing / arbitrary databases?
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.