On Jan 9, 2012, at 9:07 PM, Mason wrote: > Hi > > I have 100 tables that go from user_00 to user_99 (based on the last 2 > digits of user id). In sql, I can create a view (say 'user') and > query 'user' directly. With sqlalchemy, can I do something similar? > I would like to query the 'user' class directly, without having to > worry about which table to select from. Also, if i have a sql table > that looks like event_20120109, and a new table is created everyday. > In the old way, i will need to figure out what table to query , do > 'select * from event_201200109', and if not enough event, go 1 day in > the past, until i have enough events. So, is there some way to query > specific table? I know I can execute sql directly in sqlalchemy, but > want to see if there is smarter way to do it. Last thing is, we like > to direct the select to a specific mysql salve based on table access. > For example, select * from table1 goes to slave1 and select * from > table2 goes to slave2. Can sqlachemy be configured to go to specific > slave by examining the select on the fly?
take a look at the entity name recipe: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/EntityName Or if you just need one name at a time, you can set the "name" field of Table() to anything you want, so the code refers to "User" or "user" which then links to the name. Depends on how you want to do it. then for the slave question that's just vertical partitioning: http://www.sqlalchemy.org/docs/orm/session.html#vertical-partitioning -- 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.
