Re: [sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-23 Thread Rob Fowler
So anyone else who asks this knows, the following works: A query with just a column: qq = session.query(Configuration.name) Normally I would loop, but in this case, taking just the first column: yy = qq.column_descriptions[0]['expr'] yy.expression.table.name gives: ''configurations”

Re: [sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-22 Thread Michael Bayer
On Apr 21, 2013, at 10:04 PM, Rob Fowler mia...@gmail.com wrote: We are using the sharding module included in our application. Currently we are selecting shards based on field. This works really well, as the field that gets hashed to select the shard needs to be migrated to the other

Re: [sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-22 Thread Rob Fowler
If the query does not have a table in it we don't get the tables. For example, the following simple query gets a list of connection_strings column from the Connection table: aa = session.query(Connection.connection_string) aa.column_descriptions [{'aliased': False, 'expr':

Re: [sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-22 Thread Michael Bayer
from that expr, assuming it's a Column, you should be able to say attribute.expression.table, where attribute is that InstrumentedAttribute object. If it can be any kind of expression, then you'd need to look into some of the SQL utilities to find tables within the expression. On Apr 22,

[sqlalchemy] Getting the entity name, ideally the ORM class in the shard selector?

2013-04-21 Thread Rob Fowler
We are using the sharding module included in our application. Currently we are selecting shards based on field. This works really well, as the field that gets hashed to select the shard needs to be migrated to the other tables that exist only in that shard. Now we would like to have