Jon Nelson wrote:
> Let's say I have a database with hundreds or even thousands of tables.
> The table structure for this set of tables is *exactly* the same.
> Furthermore, let's say the name of each table is predictable.
> For example, something like:
>
> tablename_2010_03_05
>
> What I'd like to know is how to best manage making use of the ORM
> layer with these tables.
> Once I've created the engine and bound it to the metadata, wrapped
> that in a session-making-clothes, etc... how do I then go using mapper
> to associate object types with tables (since the table will change)?
>
> Do I have to autoload/reflect/whatever every table? What alternatives are
> there?

how about:

def map_a_table(tablename):
    table = Table(tablename, metadata,
         ...put the standard set of columns here..

    class Foo(object):
        pass
    Foo.__name__ = tablename
    mapper(Foo, table)
    return Foo

someone else has the "thousands of the same tables" setup and also does
this (though to be blunt their top priority is migrating off of that crazy
architecture).




>
> --
> Jon
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to