diana wrote: > Case 3) In addition to the tables common across the N shards > (table_orange, table_yellow, etc), there are a bunch of tables that > have the same table definitions, yet different (but predictable) table > names. And by a bunch, I mean thousands of each table type per shard. > > database_shard_1: > -- table_circle_1 > -- table_circle... > -- table_circle_M > -- table_....
how does your application want to reference these tables ? while this might be a little memory consuming I'd probably look into generating mappers, Tables, and classes dynamically ala the recipe http://www.sqlalchemy.org/trac/wiki/UsageRecipes/EntityName . If the table is chosen based on the attributes of the class, I'd create new instances of the class using a factory function: for i in range(1, M): table = Table("circle_%d" % i, ...) my_registry_of_classes["Circle_%d" % i] = \ map_class_to_some_table(CircleBase, table, "Circle_%d" % i) def myobject(circle): return my_registry_of_classes["Circle_%d"% circle]() x = myobject(circle=5)
-- 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.