File: horizontal_shard.html

package info (click to toggle)
sqlalchemy 0.6.3-3%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 10,744 kB
  • ctags: 15,132
  • sloc: python: 93,431; ansic: 787; makefile: 137; xml: 17
file content (192 lines) | stat: -rw-r--r-- 8,227 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        
        <title>
    Horizontal Shard
 &mdash; SQLAlchemy 0.6.3 Documentation</title>
        
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/docs.css" type="text/css" />

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '../../',
          VERSION:     '0.6.3',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
        <script type="text/javascript" src="../../_static/jquery.js"></script>
        <script type="text/javascript" src="../../_static/underscore.js"></script>
        <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/init.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="top" title="SQLAlchemy 0.6.3 Documentation" href="../../index.html" />
        <link rel="up" title="sqlalchemy.ext" href="index.html" />
        <link rel="prev" title="compiler" href="compiler.html" />
    

    </head>
    <body>
        




        <h1>SQLAlchemy 0.6.3 Documentation</h1>

        <div id="search">
        Search:
        <form class="search" action="../../search.html" method="get">
          <input type="text" name="q" size="18" /> <input type="submit" value="Search" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
        </div>

        <div class="versionheader">
            Version: <span class="versionnum">0.6.3</span> Last Updated: 07/15/2010 12:35:47
        </div>
        <div class="clearboth"></div>

        <div class="topnav">
            <div id="pagecontrol">
                <a href="../index.html">API Reference</a>
                |
                <a href="../../genindex.html">Index</a>
            
                <div class="sourcelink">(<a href="../../_sources/reference/ext/horizontal_shard.txt">view source)</div>
            </div>
            
            <div class="navbanner">
                <a class="totoc" href="../../index.html">Table of Contents</a>
                        » <a href="../index.html" title="API Reference">API Reference</a>
                        » <a href="index.html" title="sqlalchemy.ext">sqlalchemy.ext</a>
                » 
    Horizontal Shard
 
                
                
<div class="prevnext">
        Previous:
        <a href="compiler.html" title="previous chapter">compiler</a>
</div>

                <h2>
                    
    Horizontal Shard
 
                </h2>
            </div>
                <ul>
<li><a class="reference internal" href="#">Horizontal Shard</a><ul>
<li><a class="reference internal" href="#api-documentation">API Documentation</a></li>
</ul>
</li>
</ul>

            <div class="clearboth"></div>
        </div>
        
        <div class="document">
            <div class="body">
                
<div class="section" id="module-sqlalchemy.ext.horizontal_shard">
<span id="horizontal-shard"></span><h1>Horizontal Shard<a class="headerlink" href="#module-sqlalchemy.ext.horizontal_shard" title="Permalink to this headline">¶</a></h1>
<p>Horizontal sharding support.</p>
<p>Defines a rudimental &#8216;horizontal sharding&#8217; system which allows a Session to
distribute queries and persistence operations across multiple databases.</p>
<p>For a usage example, see the <a class="reference internal" href="../../examples.html#examples-sharding"><em>Horizontal Sharding</em></a> example included in 
the source distrbution.</p>
<div class="section" id="api-documentation">
<h2>API Documentation<a class="headerlink" href="#api-documentation" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="sqlalchemy.ext.horizontal_shard.ShardedSession">
<em class="property">class </em><tt class="descclassname">sqlalchemy.ext.horizontal_shard.</tt><tt class="descname">ShardedSession</tt><big>(</big><em>shard_chooser</em>, <em>id_chooser</em>, <em>query_chooser</em>, <em>shards=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.ext.horizontal_shard.ShardedSession" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="sqlalchemy.ext.horizontal_shard.ShardedSession.__init__">
<tt class="descname">__init__</tt><big>(</big><em>shard_chooser</em>, <em>id_chooser</em>, <em>query_chooser</em>, <em>shards=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.ext.horizontal_shard.ShardedSession.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a ShardedSession.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>shard_chooser</strong> &#8211; 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.</li>
<li><strong>id_chooser</strong> &#8211; 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.</li>
<li><strong>query_chooser</strong> &#8211; 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.</li>
<li><strong>shards</strong> &#8211; A dictionary of string shard names to <a class="reference internal" href="../sqlalchemy/connections.html#sqlalchemy.engine.base.Engine" title="sqlalchemy.engine.base.Engine"><tt class="xref py py-class docutils literal"><span class="pre">Engine</span></tt></a>
objects.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.ext.horizontal_shard.ShardedQuery">
<em class="property">class </em><tt class="descclassname">sqlalchemy.ext.horizontal_shard.</tt><tt class="descname">ShardedQuery</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.ext.horizontal_shard.ShardedQuery" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="sqlalchemy.ext.horizontal_shard.ShardedQuery.__init__">
<tt class="descname">__init__</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.ext.horizontal_shard.ShardedQuery.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.ext.horizontal_shard.ShardedQuery.set_shard">
<tt class="descname">set_shard</tt><big>(</big><em>shard_id</em><big>)</big><a class="headerlink" href="#sqlalchemy.ext.horizontal_shard.ShardedQuery.set_shard" title="Permalink to this definition">¶</a></dt>
<dd><p>return a new query, limited to a single shard ID.</p>
<p>all subsequent operations with the returned query will 
be against the single shard regardless of other state.</p>
</dd></dl>

</dd></dl>

</div>
</div>

            </div>
        </div>

        
        
            <div class="bottomnav">
                
<div class="prevnext">
        Previous:
        <a href="compiler.html" title="previous chapter">compiler</a>
</div>

                <div class="doc_copyright">
                    &copy; Copyright 2007, 2008, 2009, 2010, the SQLAlchemy authors and contributors.
                    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0b2+.
                </div>
            </div>
        






    </body>
</html>