On Jul 4, 2008, at 10:16 AM, lilo wrote:

>
> My shard_chooser func,shard_chooser_post, bailing out on, lk_rec =
> querylk.get([instance.username]) with an error (username is the
> primary key for Post table):
>
>  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.6-py2.5.egg/
> sqlalchemy/orm/shard.py", line 60, in get_bind
>    return self.__binds[shard_id]
> KeyError: 'l'
>
> Not sure what that means.  More likely I am not doing ShardSession
> Query get properly.  Any help appreciated.
>
> Here is the relevant code for brevity:
>
> sesslk = create_session_lookup()
> def shard_chooser_post(mapper, instance, clause=None):
>
>    querylk = sesslk.query(Lookup)
>    print "inside shard_chooser_post"
>    # ORM creates this kind of query:
>    #ShardedQuery: SELECT lookup.username AS lookup_username,
> lookup.shardname AS lookup_shardname
>    #FROM lookup ORDER BY lookup.username

its nonsensical to call upon the ShardedSession *within* the  
query_chooser def.  The ShardedSession can't do a query without a  
return value from the chooser, so that it knows which engine to  
query.   I'm fairly confused about how your scheme is to work here,  
but I'd assume that one of your shards happens to contain some  
information to be used, so call upon the desired engine directly  
within this function, i.e. engine.execute("select my_shard_id from  
my_shard_table where foo='bar'").fetchall() .   I don't quite get how  
sharding is going to help you here in the first place;  you aren't  
getting any performance/clustering advantages (since you're relying on  
a big slow query every time to one monolithic database) and you aren't  
saving on rows, either (since you have one monolithic table with a row  
for every piece of data in all the other databases).


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to