File: intro.html

package info (click to toggle)
sqlalchemy 0.9.8%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,952 kB
  • ctags: 24,534
  • sloc: python: 152,282; ansic: 1,346; makefile: 257; xml: 17
file content (352 lines) | stat: -rw-r--r-- 18,117 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        
        <title>
            
    
                Overview
             &mdash;
    SQLAlchemy 0.9 Documentation

        </title>

        
            <!-- begin iterate through SQLA + sphinx environment css_files -->
                <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
                <link rel="stylesheet" href="_static/docs.css" type="text/css" />
                <link rel="stylesheet" href="_static/sphinx_paramlinks.css" type="text/css" />
                <link rel="stylesheet" href="_static/changelog.css" type="text/css" />
            <!-- end iterate through SQLA + sphinx environment css_files -->
        

        

    

    <!-- begin layout.mako headers -->

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    './',
          VERSION:     '0.9.8',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>

    <!-- begin iterate through sphinx environment script_files -->
        <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>
    <!-- end iterate through sphinx environment script_files -->

    <script type="text/javascript" src="_static/detectmobile.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="copyright" title="Copyright" href="copyright.html" />
    <link rel="top" title="SQLAlchemy 0.9 Documentation" href="index.html" />
        <link rel="next" title="SQLAlchemy ORM" href="orm/index.html" />
        <link rel="prev" title="Table of Contents" href="contents.html" />
    <!-- end layout.mako headers -->


    </head>
    <body>
        















<div id="docs-container">





<div id="docs-top-navigation-container" class="body-background">
<div id="docs-header">
    <div id="docs-version-header">
        Release: <span class="version-num">0.9.8</span> | Release Date: October 13, 2014
    </div>

    <h1>SQLAlchemy 0.9 Documentation</h1>

</div>
</div>

<div id="docs-body-container">

    <div id="fixed-sidebar" class="withsidebar">


        <div id="docs-sidebar-popout">
            <h3><a href="index.html">SQLAlchemy 0.9 Documentation</a></h3>

            <p id="sidebar-paginate">
                    <a href="index.html" title="SQLAlchemy 0.9 Documentation">Up</a> |

                    <a href="contents.html" title="Table of Contents">Prev</a> |
                    <a href="orm/index.html" title="SQLAlchemy ORM">Next</a>
            </p>

            <p id="sidebar-topnav">
                <a href="index.html">Contents</a> |
                <a href="genindex.html">Index</a>
            </p>

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

        </div>

        <div id="docs-sidebar">

        <h3><a href="#">            
                Overview
            
        </a></h3>
        <ul>
<li><a class="reference internal" href="#">Overview</a><ul>
<li><a class="reference internal" href="#documentation-overview">Documentation Overview</a></li>
<li><a class="reference internal" href="#code-examples">Code Examples</a></li>
<li><a class="reference internal" href="#installation-guide">Installation Guide</a><ul>
<li><a class="reference internal" href="#supported-platforms">Supported Platforms</a></li>
<li><a class="reference internal" href="#supported-installation-methods">Supported Installation Methods</a></li>
<li><a class="reference internal" href="#install-via-easy-install-or-pip">Install via easy_install or pip</a></li>
<li><a class="reference internal" href="#installing-using-setup-py">Installing using setup.py</a></li>
<li><a class="reference internal" href="#installing-the-c-extensions">Installing the C Extensions</a></li>
<li><a class="reference internal" href="#installing-on-python-3">Installing on Python 3</a></li>
<li><a class="reference internal" href="#installing-a-database-api">Installing a Database API</a></li>
<li><a class="reference internal" href="#checking-the-installed-sqlalchemy-version">Checking the Installed SQLAlchemy Version</a></li>
</ul>
</li>
<li><a class="reference internal" href="#to-0-9-migration">0.8 to 0.9 Migration</a></li>
</ul>
</li>
</ul>




        </div>

    </div>

    

    <div id="docs-body" class="withsidebar" >
        
<div class="section" id="overview">
<span id="overview-toplevel"></span><span id="id1"></span><h1>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h1>
<p>The SQLAlchemy SQL Toolkit and Object Relational Mapper
is a comprehensive set of tools for working with
databases and Python. It has several distinct areas of
functionality which can be used individually or combined
together. Its major components are illustrated in below,
with component dependencies organized into layers:</p>
<img alt="_images/sqla_arch_small.png" src="_images/sqla_arch_small.png" />
<p>Above, the two most significant front-facing portions of
SQLAlchemy are the <strong>Object Relational Mapper</strong> and the
<strong>SQL Expression Language</strong>. SQL Expressions can be used
independently of the ORM. When using the ORM, the SQL
Expression language remains part of the public facing API
as it is used within object-relational configurations and
queries.</p>
<div class="section" id="documentation-overview">
<span id="doc-overview"></span><h2>Documentation Overview<a class="headerlink" href="#documentation-overview" title="Permalink to this headline">¶</a></h2>
<p>The documentation is separated into three sections: <a class="reference internal" href="orm/index.html"><em>SQLAlchemy ORM</em></a>,
<a class="reference internal" href="core/index.html"><em>SQLAlchemy Core</em></a>, and <a class="reference internal" href="dialects/index.html"><em>Dialects</em></a>.</p>
<p>In <a class="reference internal" href="orm/index.html"><em>SQLAlchemy ORM</em></a>, the Object Relational Mapper is introduced and fully
described. New users should begin with the <a class="reference internal" href="orm/tutorial.html"><em>Object Relational Tutorial</em></a>. If you
want to work with higher-level SQL which is constructed automatically for you,
as well as management of Python objects, proceed to this tutorial.</p>
<p>In <a class="reference internal" href="core/index.html"><em>SQLAlchemy Core</em></a>, the breadth of SQLAlchemy&#8217;s SQL and database
integration and description services are documented, the core of which is the
SQL Expression language. The SQL Expression Language is a toolkit all its own,
independent of the ORM package, which can be used to construct manipulable SQL
expressions which can be programmatically constructed, modified, and executed,
returning cursor-like result sets. In contrast to the ORM&#8217;s domain-centric
mode of usage, the expression language provides a schema-centric usage
paradigm. New users should begin here with <a class="reference internal" href="core/tutorial.html"><em>SQL Expression Language Tutorial</em></a>.
SQLAlchemy engine, connection, and pooling services are also described in
<a class="reference internal" href="core/index.html"><em>SQLAlchemy Core</em></a>.</p>
<p>In <a class="reference internal" href="dialects/index.html"><em>Dialects</em></a>, reference documentation for all provided
database and DBAPI backends is provided.</p>
</div>
<div class="section" id="code-examples">
<h2>Code Examples<a class="headerlink" href="#code-examples" title="Permalink to this headline">¶</a></h2>
<p>Working code examples, mostly regarding the ORM, are included in the
SQLAlchemy distribution. A description of all the included example
applications is at <a class="reference internal" href="orm/examples.html"><em>ORM Examples</em></a>.</p>
<p>There is also a wide variety of examples involving both core SQLAlchemy
constructs as well as the ORM on the wiki.  See
<a class="reference external" href="http://www.sqlalchemy.org/trac/wiki/UsageRecipes">Theatrum Chemicum</a>.</p>
</div>
<div class="section" id="installation-guide">
<span id="installation"></span><h2>Installation Guide<a class="headerlink" href="#installation-guide" title="Permalink to this headline">¶</a></h2>
<div class="section" id="supported-platforms">
<h3>Supported Platforms<a class="headerlink" href="#supported-platforms" title="Permalink to this headline">¶</a></h3>
<p>SQLAlchemy has been tested against the following platforms:</p>
<ul class="simple">
<li>cPython since version 2.6, through the 2.xx series</li>
<li>cPython version 3, throughout all 3.xx series</li>
<li><a class="reference external" href="http://pypy.org/">Pypy</a> 2.1 or greater</li>
</ul>
<div class="versionchanged">
<p><span>Changed in version 0.9: </span>Python 2.6 is now the minimum Python version supported.</p>
</div>
</div>
<div class="section" id="supported-installation-methods">
<h3>Supported Installation Methods<a class="headerlink" href="#supported-installation-methods" title="Permalink to this headline">¶</a></h3>
<p>SQLAlchemy supports installation using standard Python &#8220;distutils&#8221; or
&#8220;setuptools&#8221; methodologies. An overview of potential setups is as follows:</p>
<ul class="simple">
<li><strong>Plain Python Distutils</strong> - SQLAlchemy can be installed with a clean
Python install using the services provided via <a class="reference external" href="http://docs.python.org/distutils/">Python Distutils</a>,
using the <tt class="docutils literal"><span class="pre">setup.py</span></tt> script. The C extensions as well as Python 3 builds are supported.</li>
<li><strong>Setuptools or Distribute</strong> - When using <a class="reference external" href="http://pypi.python.org/pypi/setuptools/">setuptools</a>,
SQLAlchemy can be installed via <tt class="docutils literal"><span class="pre">setup.py</span></tt> or <tt class="docutils literal"><span class="pre">easy_install</span></tt>, and the C
extensions are supported.</li>
<li><strong>pip</strong> - <a class="reference external" href="http://pypi.python.org/pypi/pip/">pip</a> is an installer that
rides on top of <tt class="docutils literal"><span class="pre">setuptools</span></tt> or <tt class="docutils literal"><span class="pre">distribute</span></tt>, replacing the usage
of <tt class="docutils literal"><span class="pre">easy_install</span></tt>.  It is often preferred for its simpler mode of usage.</li>
</ul>
</div>
<div class="section" id="install-via-easy-install-or-pip">
<h3>Install via easy_install or pip<a class="headerlink" href="#install-via-easy-install-or-pip" title="Permalink to this headline">¶</a></h3>
<p>When <tt class="docutils literal"><span class="pre">easy_install</span></tt> or <tt class="docutils literal"><span class="pre">pip</span></tt> is available, the distribution can be
downloaded from Pypi and installed in one step:</p>
<div class="highlight-python"><pre>easy_install SQLAlchemy</pre>
</div>
<p>Or with pip:</p>
<div class="highlight-python"><pre>pip install SQLAlchemy</pre>
</div>
<p>This command will download the latest version of SQLAlchemy from the <a class="reference external" href="http://pypi.python.org/pypi/SQLAlchemy">Python
Cheese Shop</a> and install it to your system.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Beta releases of SQLAlchemy may not be present on Pypi, and may instead
require a direct download first.</p>
</div>
</div>
<div class="section" id="installing-using-setup-py">
<h3>Installing using setup.py<a class="headerlink" href="#installing-using-setup-py" title="Permalink to this headline">¶</a></h3>
<p>Otherwise, you can install from the distribution using the <tt class="docutils literal"><span class="pre">setup.py</span></tt> script:</p>
<div class="highlight-python"><pre>python setup.py install</pre>
</div>
</div>
<div class="section" id="installing-the-c-extensions">
<h3>Installing the C Extensions<a class="headerlink" href="#installing-the-c-extensions" title="Permalink to this headline">¶</a></h3>
<p>SQLAlchemy includes C extensions which provide an extra speed boost for
dealing with result sets.   The extensions are supported on both the 2.xx
and 3.xx series of cPython.</p>
<div class="versionchanged">
<p><span>Changed in version 0.9.0: </span>The C extensions now compile on Python 3 as well as Python 2.</p>
</div>
<p><tt class="docutils literal"><span class="pre">setup.py</span></tt> will automatically build the extensions if an appropriate platform is
detected. If the build of the C extensions fails, due to missing compiler or
other issue, the setup process will output a warning message, and re-run the
build without the C extensions, upon completion reporting final status.</p>
<p>To run the build/install without even attempting to compile the C extensions,
the <tt class="docutils literal"><span class="pre">DISABLE_SQLALCHEMY_CEXT</span></tt> environment variable may be specified.  The
use case for this is either for special testing circumstances, or in the rare
case of compatibility/build issues not overcome by the usual &#8220;rebuild&#8221;
mechanism:</p>
<div class="highlight-python"><pre># *** only in SQLAlchemy 0.9.4 / 0.8.6 or greater ***
export DISABLE_SQLALCHEMY_CEXT=1; python setup.py install</pre>
</div>
<div class="versionadded">
<p><span>New in version 0.9.4,0.8.6: </span>Support for disabling the build of
C extensions using the <tt class="docutils literal"><span class="pre">DISABLE_SQLALCHEMY_CEXT</span></tt> environment variable
has been added.  This allows control of C extension building whether or not
setuptools is available, and additionally works around the fact that
setuptools will possibly be <strong>removing support</strong> for command-line switches
such as <tt class="docutils literal"><span class="pre">--without-extensions</span></tt> in a future release.</p>
<p>For versions of SQLAlchemy prior to 0.9.4 or 0.8.6, the
<tt class="docutils literal"><span class="pre">--without-cextensions</span></tt> option may be used to disable the attempt to build
C extensions, provided setupools is in use, and provided the <tt class="docutils literal"><span class="pre">Feature</span></tt>
construct is supported by the installed version of setuptools:</p>
<div class="highlight-python"><pre>python setup.py --without-cextensions install</pre>
</div>
<p>Or with pip:</p>
<div class="highlight-python"><pre>pip install --global-option='--without-cextensions' SQLAlchemy</pre>
</div>
</div>
</div>
<div class="section" id="installing-on-python-3">
<h3>Installing on Python 3<a class="headerlink" href="#installing-on-python-3" title="Permalink to this headline">¶</a></h3>
<p>SQLAlchemy runs directly on Python 2 or Python 3, and can be installed in
either environment without any adjustments or code conversion.</p>
<div class="versionchanged">
<p><span>Changed in version 0.9.0: </span>Python 3 is now supported in place with no 2to3 step
required.</p>
</div>
</div>
<div class="section" id="installing-a-database-api">
<h3>Installing a Database API<a class="headerlink" href="#installing-a-database-api" title="Permalink to this headline">¶</a></h3>
<p>SQLAlchemy is designed to operate with a <a class="reference internal" href="glossary.html#term-dbapi"><em class="xref std std-term">DBAPI</em></a> implementation built for a
particular database, and includes support for the most popular databases.
The individual database sections in <a class="reference internal" href="dialects/index.html"><em>Dialects</em></a> enumerate
the available DBAPIs for each database, including external links.</p>
</div>
<div class="section" id="checking-the-installed-sqlalchemy-version">
<h3>Checking the Installed SQLAlchemy Version<a class="headerlink" href="#checking-the-installed-sqlalchemy-version" title="Permalink to this headline">¶</a></h3>
<p>This documentation covers SQLAlchemy version 0.9. If you&#8217;re working on a
system that already has SQLAlchemy installed, check the version from your
Python prompt like this:</p>
<div class="highlight-python+sql"><div class="highlight"><pre><span class="o">&gt;&gt;&gt;</span> <span class="kn">import</span> <span class="nn">sqlalchemy</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">sqlalchemy</span><span class="o">.</span><span class="n">__version__</span> 
<span class="mf">0.9</span><span class="o">.</span><span class="mi">0</span></pre></div>
</div>
</div>
</div>
<div class="section" id="to-0-9-migration">
<span id="migration"></span><h2>0.8 to 0.9 Migration<a class="headerlink" href="#to-0-9-migration" title="Permalink to this headline">¶</a></h2>
<p>Notes on what&#8217;s changed from 0.8 to 0.9 is available here at <a class="reference internal" href="changelog/migration_09.html"><em>What&#8217;s New in SQLAlchemy 0.9?</em></a>.</p>
</div>
</div>

    </div>

</div>

<div id="docs-bottom-navigation" class="docs-navigation-links">
        Previous:
        <a href="contents.html" title="previous chapter">Table of Contents</a>
        Next:
        <a href="orm/index.html" title="next chapter">SQLAlchemy ORM</a>

    <div id="docs-copyright">
        &copy; <a href="copyright.html">Copyright</a> 2007-2014, the SQLAlchemy authors and contributors.
        Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2b1.
    </div>
</div>

</div>

        
    </body>
</html>