SQLAlchemy 0.6 Documentation
Search:
Release: 0.6.9 | Release Date: May 5, 2012
- Prev: Ordering List
- Next: SqlSoup
- Table of Contents | Index | view source
SQLAlchemy 0.6 Documentation
» SQLAlchemy ORM
» ORM Extensions
»
Horizontal Sharding
Horizontal Sharding
Horizontal Sharding¶
Horizontal sharding support.
Defines a rudimental ‘horizontal sharding’ system which allows a Session to distribute queries and persistence operations across multiple databases.
For a usage example, see the Horizontal Sharding example included in the source distrbution.
API Documentation¶
- class sqlalchemy.ext.horizontal_shard.ShardedSession(shard_chooser, id_chooser, query_chooser, shards=None, query_cls=<class 'sqlalchemy.ext.horizontal_shard.ShardedQuery'>, **kwargs)¶
- __init__(shard_chooser, id_chooser, query_chooser, shards=None, query_cls=<class 'sqlalchemy.ext.horizontal_shard.ShardedQuery'>, **kwargs)¶
Construct a ShardedSession.
Parameters: - shard_chooser – A callable which, passed a Mapper, a mapped instance, and possibly a SQL clause, returns a shard ID. This id may be based off of the attributes present within the object, or on some round-robin scheme. If the scheme is based on a selection, it should set whatever state on the instance to mark it in the future as participating in that shard.
- id_chooser – A callable, passed a query and a tuple of identity values, which should return a list of shard ids where the ID might reside. The databases will be queried in the order of this listing.
- query_chooser – For a given Query, returns the list of shard_ids where the query should be issued. Results from all shards returned will be combined together into a single listing.
- shards – A dictionary of string shard names to Engine objects.
Previous:
Ordering List
Next:
SqlSoup
