File: //opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyc
�
���ec @ s� d Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d g Z
d e f d
� � YZ d e f d � � YZ d � Z
d
S( s 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 :ref:`examples_sharding` example included in
the source distribution.
i ( t event( t exc( t inspect( t util( t Query( t Sessiont ShardedSessiont ShardedQueryc B s e Z d � Z d � Z RS( c O sS t t | � j | | � | j j | _ | j j | _ | j j | _ d | _ d S( N( t superR t __init__t sessiont
id_choosert
query_choosert execute_choosert Nonet _shard_id( t selft argst kwargs( ( sP /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR s
c C s | j d | � S( s� Return a new query, limited to a single shard ID.
All subsequent operations with the returned query will
be against the single shard regardless of other state.
The shard_id can be passed for a 2.0 style execution to the
bind_arguments dictionary of :meth:`.Session.execute`::
results = session.execute(
stmt,
bind_arguments={"shard_id": "my_shard"}
)
t _sa_shard_id( t execution_options( R t shard_id( ( sP /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyt set_shard$ s ( t __name__t
__module__R R ( ( ( sP /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/ext/horizontal_shard.pyR s c B sb e Z d d e d � Z d d d � Z d � Z d d d d � Z d d d d d � Z d � Z RS( c s� | j d d � � t t | � j d | | � t j | d t d t �| | _ | | _
� r� t j d d � | r� t
j d � � n � f d � } | | _ n | | _ � | _ i | _ | d k r� x% | D] } | j | | | � q� Wn d S(
s� Construct a ShardedSession.
:param 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.
:param 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.
:param execute_chooser: For a given :class:`.ORMExecuteState`,
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.
.. versionchanged:: 1.4 The ``execute_chooser`` parameter
supersedes the ``query_chooser`` parameter.
:param shards: A dictionary of string shard names
to :class:`~sqlalchemy.engine.Engine` objects.
R t query_clst do_orm_executet retvalsM The ``query_choser`` parameter is deprecated; please use ``execute_chooser``.s 1.4s>