~ubuntu-branches/debian/sid/sqlalchemy/sid

« back to all changes in this revision

Viewing changes to doc/dialects/postgresql.html

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski
  • Date: 2014-06-27 20:17:13 UTC
  • mfrom: (1.4.28)
  • Revision ID: package-import@ubuntu.com-20140627201713-g6p1kq8q1qenztrv
Tags: 0.9.6-1
* New upstream release
* Remove Python 3.X build tag files, thanks to Matthias Urlichs for the
  patch (closes: #747852)
* python-fdb isn't in the Debian archive yet so default dialect for firebird://
  URLs is changed to obsolete kinterbasdb, thanks to Russell Stuart for the
  patch (closes: #752145)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    <script type="text/javascript">
33
33
      var DOCUMENTATION_OPTIONS = {
34
34
          URL_ROOT:    '../',
35
 
          VERSION:     '0.9.4',
 
35
          VERSION:     '0.9.6',
36
36
          COLLAPSE_MODINDEX: false,
37
37
          FILE_SUFFIX: '.html'
38
38
      };
44
44
        <script type="text/javascript" src="../_static/doctools.js"></script>
45
45
    <!-- end iterate through sphinx environment script_files -->
46
46
 
 
47
    <script type="text/javascript" src="../_static/detectmobile.js"></script>
47
48
    <script type="text/javascript" src="../_static/init.js"></script>
48
49
    <link rel="index" title="Index" href="../genindex.html" />
49
50
    <link rel="search" title="Search" href="../search.html" />
69
70
 
70
71
 
71
72
 
 
73
 
72
74
<div id="docs-container">
73
75
 
74
76
 
75
77
 
76
78
 
 
79
 
 
80
<div id="docs-top-navigation-container" class="body-background">
77
81
<div id="docs-header">
 
82
    <div id="docs-version-header">
 
83
        Release: <span class="version-num">0.9.6</span> | Release Date: June 23, 2014
 
84
    </div>
 
85
 
78
86
    <h1>SQLAlchemy 0.9 Documentation</h1>
79
87
 
80
 
    <div id="docs-search">
81
 
    Search:
82
 
    <form class="search" action="../search.html" method="get">
83
 
      <input type="text" name="q" size="18" /> <input type="submit" value="Search" />
84
 
      <input type="hidden" name="check_keywords" value="yes" />
85
 
      <input type="hidden" name="area" value="default" />
86
 
    </form>
87
 
    </div>
88
 
 
89
 
    <div id="docs-version-header">
90
 
        Release: <span class="version-num">0.9.4</span> | Release Date: March 28, 2014
91
 
 
92
 
 
93
 
    </div>
94
 
 
95
 
</div>
96
 
 
97
 
<div id="docs-top-navigation">
98
 
    <div id="docs-top-page-control" class="docs-navigation-links">
 
88
</div>
 
89
</div>
 
90
 
 
91
<div id="docs-body-container">
 
92
 
 
93
    <div id="fixed-sidebar" class="withsidebar">
 
94
 
 
95
 
 
96
        <div id="docs-sidebar-popout">
 
97
            <h3><a href="../index.html">SQLAlchemy 0.9 Documentation</a></h3>
 
98
 
 
99
            <p id="sidebar-paginate">
 
100
                    <a href="index.html" title="Dialects">Up</a> |
 
101
 
 
102
                    <a href="oracle.html" title="Oracle">Prev</a> |
 
103
                    <a href="sqlite.html" title="SQLite">Next</a>
 
104
            </p>
 
105
 
 
106
            <p id="sidebar-topnav">
 
107
                <a href="../index.html">Contents</a> |
 
108
                <a href="../genindex.html">Index</a>
 
109
            </p>
 
110
 
 
111
            <div id="sidebar-search">
 
112
                <form class="search" action="../search.html" method="get">
 
113
                  <input type="text" name="q" size="12" /> <input type="submit" value="Search" />
 
114
                  <input type="hidden" name="check_keywords" value="yes" />
 
115
                  <input type="hidden" name="area" value="default" />
 
116
                </form>
 
117
            </div>
 
118
 
 
119
        </div>
 
120
 
 
121
        <div id="docs-sidebar">
 
122
 
 
123
        <h3><a href="#">            
 
124
                PostgreSQL
 
125
            
 
126
        </a></h3>
99
127
        <ul>
100
 
            <li>Prev:
101
 
            <a href="oracle.html" title="previous chapter">Oracle</a>
102
 
            </li>
103
 
            <li>Next:
104
 
            <a href="sqlite.html" title="next chapter">SQLite</a>
105
 
            </li>
106
 
 
107
 
        <li>
108
 
            <a href="../contents.html">Table of Contents</a> |
109
 
            <a href="../genindex.html">Index</a>
110
 
            | <a href="../_sources/dialects/postgresql.txt">view source
111
 
        </li>
112
 
        </ul>
113
 
    </div>
114
 
 
115
 
    <div id="docs-navigation-banner">
116
 
        <a href="../index.html">SQLAlchemy 0.9 Documentation</a>
117
 
                » <a href="index.html" title="Dialects">Dialects</a>
118
 
        » 
119
 
                PostgreSQL
120
 
            
121
 
 
122
 
        <h2>
123
 
            
124
 
                PostgreSQL
125
 
            
126
 
        </h2>
127
 
    </div>
128
 
 
129
 
</div>
130
 
 
131
 
<div id="docs-body-container">
132
 
 
133
 
    <div id="docs-sidebar">
134
 
    <h3><a href="../index.html">Table of Contents</a></h3>
135
 
    <ul>
136
128
<li><a class="reference internal" href="#">PostgreSQL</a><ul>
137
129
<li><a class="reference internal" href="#dialect-postgresql">Support for the PostgreSQL database.</a></li>
138
130
<li><a class="reference internal" href="#sequences-serial">Sequences/SERIAL</a></li>
174
166
<li><a class="reference internal" href="#dialect-postgresql-pg8000-url">DBAPI</a></li>
175
167
<li><a class="reference internal" href="#dialect-postgresql-pg8000-connect">Connecting</a></li>
176
168
<li><a class="reference internal" href="#id3">Unicode</a></li>
177
 
<li><a class="reference internal" href="#interval">Interval</a></li>
 
169
<li><a class="reference internal" href="#pg8000-transaction-isolation-level">pg8000 Transaction Isolation Level</a></li>
178
170
</ul>
179
171
</li>
180
172
<li><a class="reference internal" href="#module-sqlalchemy.dialects.postgresql.zxjdbc">zxjdbc</a><ul>
187
179
</ul>
188
180
 
189
181
 
190
 
    <h4>Previous Topic</h4>
191
 
    <p>
192
 
    <a href="oracle.html" title="previous chapter">Oracle</a>
193
 
    </p>
194
 
    <h4>Next Topic</h4>
195
 
    <p>
196
 
    <a href="sqlite.html" title="next chapter">SQLite</a>
197
 
    </p>
198
 
 
199
 
 
200
 
    <h4>Quick Search</h4>
201
 
    <p>
202
 
    <form class="search" action="../search.html" method="get">
203
 
      <input type="text" name="q" size="18" /> <input type="submit" value="Search" />
204
 
      <input type="hidden" name="check_keywords" value="yes" />
205
 
      <input type="hidden" name="area" value="default" />
206
 
    </form>
207
 
    </p>
 
182
 
 
183
 
 
184
        </div>
208
185
 
209
186
    </div>
210
187
 
 
188
    
 
189
 
211
190
    <div id="docs-body" class="withsidebar" >
212
191
        
213
192
<div class="section" id="module-sqlalchemy.dialects.postgresql.base">
277
256
<li><tt class="docutils literal"><span class="pre">REPEATABLE</span> <span class="pre">READ</span></tt></li>
278
257
<li><tt class="docutils literal"><span class="pre">SERIALIZABLE</span></tt></li>
279
258
</ul>
280
 
<p>The <a class="reference internal" href="#module-sqlalchemy.dialects.postgresql.psycopg2" title="sqlalchemy.dialects.postgresql.psycopg2"><tt class="xref py py-mod docutils literal"><span class="pre">psycopg2</span></tt></a> dialect also offers the special level <tt class="docutils literal"><span class="pre">AUTOCOMMIT</span></tt>.  See
281
 
<a class="reference internal" href="#psycopg2-isolation-level"><em>Psycopg2 Transaction Isolation Level</em></a> for details.</p>
 
259
<p>The <a class="reference internal" href="#module-sqlalchemy.dialects.postgresql.psycopg2" title="sqlalchemy.dialects.postgresql.psycopg2"><tt class="xref py py-mod docutils literal"><span class="pre">psycopg2</span></tt></a> and
 
260
<a class="reference internal" href="#module-sqlalchemy.dialects.postgresql.pg8000" title="sqlalchemy.dialects.postgresql.pg8000"><tt class="xref py py-mod docutils literal"><span class="pre">pg8000</span></tt></a> dialects also offer the
 
261
special level <tt class="docutils literal"><span class="pre">AUTOCOMMIT</span></tt>.</p>
 
262
<div class="admonition seealso">
 
263
<p class="first admonition-title">See also</p>
 
264
<p><a class="reference internal" href="#psycopg2-isolation-level"><em>Psycopg2 Transaction Isolation Level</em></a></p>
 
265
<p class="last"><a class="reference internal" href="#pg8000-isolation-level"><em>pg8000 Transaction Isolation Level</em></a></p>
 
266
</div>
282
267
</div>
283
268
<div class="section" id="remote-schema-table-introspection-and-postgresql-search-path">
284
269
<span id="postgresql-schema-reflection"></span><h2>Remote-Schema Table Introspection and Postgresql search_path<a class="headerlink" href="#remote-schema-table-introspection-and-postgresql-search-path" title="Permalink to this headline">¶</a></h2>
519
504
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.dialects.postgresql</span> <span class="kn">import</span> \
520
505
    <span class="n">ARRAY</span><span class="p">,</span> <span class="n">BIGINT</span><span class="p">,</span> <span class="n">BIT</span><span class="p">,</span> <span class="n">BOOLEAN</span><span class="p">,</span> <span class="n">BYTEA</span><span class="p">,</span> <span class="n">CHAR</span><span class="p">,</span> <span class="n">CIDR</span><span class="p">,</span> <span class="n">DATE</span><span class="p">,</span> \
521
506
    <span class="n">DOUBLE_PRECISION</span><span class="p">,</span> <span class="n">ENUM</span><span class="p">,</span> <span class="n">FLOAT</span><span class="p">,</span> <span class="n">HSTORE</span><span class="p">,</span> <span class="n">INET</span><span class="p">,</span> <span class="n">INTEGER</span><span class="p">,</span> \
522
 
    <span class="n">INTERVAL</span><span class="p">,</span> <span class="n">JSON</span><span class="p">,</span> <span class="n">MACADDR</span><span class="p">,</span> <span class="n">NUMERIC</span><span class="p">,</span> <span class="n">REAL</span><span class="p">,</span> <span class="n">SMALLINT</span><span class="p">,</span> <span class="n">TEXT</span><span class="p">,</span> <span class="n">TIME</span><span class="p">,</span> \
 
507
    <span class="n">INTERVAL</span><span class="p">,</span> <span class="n">JSON</span><span class="p">,</span> <span class="n">MACADDR</span><span class="p">,</span> <span class="n">NUMERIC</span><span class="p">,</span> <span class="n">OID</span><span class="p">,</span> <span class="n">REAL</span><span class="p">,</span> <span class="n">SMALLINT</span><span class="p">,</span> <span class="n">TEXT</span><span class="p">,</span> <span class="n">TIME</span><span class="p">,</span> \
523
508
    <span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">UUID</span><span class="p">,</span> <span class="n">VARCHAR</span><span class="p">,</span> <span class="n">INT4RANGE</span><span class="p">,</span> <span class="n">INT8RANGE</span><span class="p">,</span> <span class="n">NUMRANGE</span><span class="p">,</span> \
524
509
    <span class="n">DATERANGE</span><span class="p">,</span> <span class="n">TSRANGE</span><span class="p">,</span> <span class="n">TSTZRANGE</span><span class="p">,</span> <span class="n">TSVECTOR</span></pre></div>
525
510
</div>
559
544
 
560
545
<dl class="class">
561
546
<dt id="sqlalchemy.dialects.postgresql.ARRAY">
562
 
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.postgresql.</tt><tt class="descname">ARRAY</tt><big>(</big><em>item_type</em>, <em>as_tuple=False</em>, <em>dimensions=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.postgresql.ARRAY" title="Permalink to this definition">¶</a></dt>
 
547
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.postgresql.</tt><tt class="descname">ARRAY</tt><big>(</big><em>item_type</em>, <em>as_tuple=False</em>, <em>dimensions=None</em>, <em>zero_indexes=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.postgresql.ARRAY" title="Permalink to this definition">¶</a></dt>
563
548
<dd><p>Bases: <a class="reference internal" href="../core/types.html#sqlalchemy.types.Concatenable" title="sqlalchemy.types.Concatenable"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.Concatenable</span></tt></a>, <a class="reference internal" href="../core/types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.TypeEngine</span></tt></a></p>
564
549
<p>Postgresql ARRAY type.</p>
565
550
<p>Represents values as Python lists.</p>
722
707
 
723
708
<dl class="method">
724
709
<dt id="sqlalchemy.dialects.postgresql.ARRAY.__init__">
725
 
<tt class="descclassname">ARRAY.</tt><tt class="descname">__init__</tt><big>(</big><em>item_type</em>, <em>as_tuple=False</em>, <em>dimensions=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.postgresql.ARRAY.__init__" title="Permalink to this definition">¶</a></dt>
 
710
<tt class="descclassname">ARRAY.</tt><tt class="descname">__init__</tt><big>(</big><em>item_type</em>, <em>as_tuple=False</em>, <em>dimensions=None</em>, <em>zero_indexes=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.postgresql.ARRAY.__init__" title="Permalink to this definition">¶</a></dt>
726
711
<dd><p>Construct an ARRAY.</p>
727
712
<p>E.g.:</p>
728
713
<div class="highlight-python"><div class="highlight"><pre><span class="n">Column</span><span class="p">(</span><span class="s">&#39;myarray&#39;</span><span class="p">,</span> <span class="n">ARRAY</span><span class="p">(</span><span class="n">Integer</span><span class="p">))</span></pre></div>
748
733
Note that PG arrays are always implicitly &#8220;non-dimensioned&#8221;,
749
734
meaning they can store any number of dimensions no matter how
750
735
they were declared.</li>
 
736
<li><span class="target" id="sqlalchemy.dialects.postgresql.ARRAY.params.zero_indexes"></span><strong>zero_indexes=False</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.postgresql.ARRAY.params.zero_indexes">¶</a> &#8211; <p>when True, index values will be converted
 
737
between Python zero-based and Postgresql one-based indexes, e.g.
 
738
a value of one will be added to all index values before passing
 
739
to the database.</p>
 
740
<div class="versionadded">
 
741
<p><span>New in version 0.9.5.</span></p>
 
742
</div>
 
743
</li>
751
744
</ul>
752
745
</td>
753
746
</tr>
1325
1318
</dd></dl>
1326
1319
 
1327
1320
<dl class="class">
 
1321
<dt id="sqlalchemy.dialects.postgresql.OID">
 
1322
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.postgresql.</tt><tt class="descname">OID</tt><a class="headerlink" href="#sqlalchemy.dialects.postgresql.OID" title="Permalink to this definition">¶</a></dt>
 
1323
<dd><p>Bases: <a class="reference internal" href="../core/types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.TypeEngine</span></tt></a></p>
 
1324
<p>Provide the Postgresql OID type.</p>
 
1325
<div class="versionadded">
 
1326
<p><span>New in version 0.9.5.</span></p>
 
1327
</div>
 
1328
<dl class="attribute">
 
1329
<dt id="sqlalchemy.dialects.postgresql.OID.__init__">
 
1330
<tt class="descname">__init__</tt><a class="headerlink" href="#sqlalchemy.dialects.postgresql.OID.__init__" title="Permalink to this definition">¶</a></dt>
 
1331
<dd><p>x.__init__(...) initializes x; see help(type(x)) for signature</p>
 
1332
</dd></dl>
 
1333
 
 
1334
</dd></dl>
 
1335
 
 
1336
<dl class="class">
1328
1337
<dt id="sqlalchemy.dialects.postgresql.REAL">
1329
1338
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.postgresql.</tt><tt class="descname">REAL</tt><big>(</big><em>precision=None</em>, <em>asdecimal=False</em>, <em>decimal_return_scale=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.postgresql.REAL" title="Permalink to this definition">¶</a></dt>
1330
1339
<dd><p>Bases: <a class="reference internal" href="../core/types.html#sqlalchemy.types.Float" title="sqlalchemy.types.Float"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.Float</span></tt></a></p>
1579
1588
<tt class="docutils literal"><span class="pre">psycopg2</span></tt>, it&#8217;s recommended to upgrade to version 2.5 or later
1580
1589
before using these column types.</p>
1581
1590
</div>
 
1591
<p>When instantiating models that use these column types, you should pass
 
1592
whatever data type is expected by the DBAPI driver you&#8217;re using for
 
1593
the column type. For <a class="reference external" href="http://pythonhosted.org/psycopg2/module.html#psycopg2" title="(in Psycopg v2.5)"><tt class="xref py py-mod docutils literal"><span class="pre">psycopg2</span></tt></a> these are
 
1594
<a class="reference external" href="http://pythonhosted.org/psycopg2/extras.html#psycopg2.extras.NumericRange" title="(in Psycopg v2.5)"><tt class="xref py py-class docutils literal"><span class="pre">NumericRange</span></tt></a>,
 
1595
<a class="reference external" href="http://pythonhosted.org/psycopg2/extras.html#psycopg2.extras.DateRange" title="(in Psycopg v2.5)"><tt class="xref py py-class docutils literal"><span class="pre">DateRange</span></tt></a>,
 
1596
<a class="reference external" href="http://pythonhosted.org/psycopg2/extras.html#psycopg2.extras.DateTimeRange" title="(in Psycopg v2.5)"><tt class="xref py py-class docutils literal"><span class="pre">DateTimeRange</span></tt></a> and
 
1597
<a class="reference external" href="http://pythonhosted.org/psycopg2/extras.html#psycopg2.extras.DateTimeTZRange" title="(in Psycopg v2.5)"><tt class="xref py py-class docutils literal"><span class="pre">DateTimeTZRange</span></tt></a> or the class you&#8217;ve
 
1598
registered with <a class="reference external" href="http://pythonhosted.org/psycopg2/extras.html#psycopg2.extras.register_range" title="(in Psycopg v2.5)"><tt class="xref py py-func docutils literal"><span class="pre">register_range()</span></tt></a>.</p>
 
1599
<p>For example:</p>
 
1600
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">psycopg2.extras</span> <span class="kn">import</span> <span class="n">DateTimeRange</span>
 
1601
<span class="kn">from</span> <span class="nn">sqlalchemy.dialects.postgresql</span> <span class="kn">import</span> <span class="n">TSRANGE</span>
 
1602
 
 
1603
<span class="k">class</span> <span class="nc">RoomBooking</span><span class="p">(</span><span class="n">Base</span><span class="p">):</span>
 
1604
 
 
1605
    <span class="n">__tablename__</span> <span class="o">=</span> <span class="s">&#39;room_booking&#39;</span>
 
1606
 
 
1607
    <span class="n">room</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="n">Integer</span><span class="p">(),</span> <span class="n">primary_key</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
 
1608
    <span class="n">during</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="n">TSRANGE</span><span class="p">())</span>
 
1609
 
 
1610
<span class="n">booking</span> <span class="o">=</span> <span class="n">RoomBooking</span><span class="p">(</span>
 
1611
    <span class="n">room</span><span class="o">=</span><span class="mi">101</span><span class="p">,</span>
 
1612
    <span class="n">during</span><span class="o">=</span><span class="n">DateTimeRange</span><span class="p">(</span><span class="n">datetime</span><span class="p">(</span><span class="mi">2013</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">23</span><span class="p">),</span> <span class="bp">None</span><span class="p">)</span>
 
1613
<span class="p">)</span></pre></div>
 
1614
</div>
1582
1615
</div>
1583
1616
</div>
1584
1617
<div class="section" id="postgresql-constraint-types">
1624
1657
<p>For example:</p>
1625
1658
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.dialects.postgresql</span> <span class="kn">import</span> <span class="n">ExcludeConstraint</span><span class="p">,</span> <span class="n">TSRANGE</span>
1626
1659
 
1627
 
<span class="k">class</span> <span class="nc">RoomBookings</span><span class="p">(</span><span class="n">Base</span><span class="p">):</span>
 
1660
<span class="k">class</span> <span class="nc">RoomBooking</span><span class="p">(</span><span class="n">Base</span><span class="p">):</span>
 
1661
 
 
1662
    <span class="n">__tablename__</span> <span class="o">=</span> <span class="s">&#39;room_booking&#39;</span>
1628
1663
 
1629
1664
    <span class="n">room</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="n">Integer</span><span class="p">(),</span> <span class="n">primary_key</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
1630
1665
    <span class="n">during</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="n">TSRANGE</span><span class="p">())</span>
1666
1701
way of enabling this mode on a per-execution basis.</li>
1667
1702
<li><tt class="docutils literal"><span class="pre">use_native_unicode</span></tt>: Enable the usage of Psycopg2 &#8220;native unicode&#8221; mode
1668
1703
per connection.  True by default.</li>
1669
 
<li><tt class="docutils literal"><span class="pre">isolation_level</span></tt>: This option, available for all Posgtresql dialects,
 
1704
<li><tt class="docutils literal"><span class="pre">isolation_level</span></tt>: This option, available for all PostgreSQL dialects,
1670
1705
includes the <tt class="docutils literal"><span class="pre">AUTOCOMMIT</span></tt> isolation level when using the psycopg2
1671
1706
dialect.  See <a class="reference internal" href="#psycopg2-isolation-level"><em>Psycopg2 Transaction Isolation Level</em></a>.</li>
1672
1707
</ul>
1729
1764
<a class="reference internal" href="../core/engines.html#sqlalchemy.create_engine" title="sqlalchemy.create_engine"><tt class="xref py py-func docutils literal"><span class="pre">create_engine()</span></tt></a>.</p>
1730
1765
</div>
1731
1766
<p>SQLAlchemy can also be instructed to skip the usage of the psycopg2
1732
 
<tt class="docutils literal"><span class="pre">UNICODE</span></tt> extension and to instead utilize it&#8217;s own unicode encode/decode
 
1767
<tt class="docutils literal"><span class="pre">UNICODE</span></tt> extension and to instead utilize its own unicode encode/decode
1733
1768
services, which are normally reserved only for those DBAPIs that don&#8217;t
1734
1769
fully support unicode directly.  Passing <tt class="docutils literal"><span class="pre">use_native_unicode=False</span></tt> to
1735
1770
<a class="reference internal" href="../core/engines.html#sqlalchemy.create_engine" title="sqlalchemy.create_engine"><tt class="xref py py-func docutils literal"><span class="pre">create_engine()</span></tt></a> will disable usage of <tt class="docutils literal"><span class="pre">psycopg2.extensions.UNICODE</span></tt>.
1767
1802
<p><span>New in version 0.8.2: </span>support for AUTOCOMMIT isolation level when using
1768
1803
psycopg2.</p>
1769
1804
</div>
 
1805
<div class="admonition seealso">
 
1806
<p class="first admonition-title">See also</p>
 
1807
<p><a class="reference internal" href="#postgresql-isolation-level"><em>Transaction Isolation Level</em></a></p>
 
1808
<p class="last"><a class="reference internal" href="#pg8000-isolation-level"><em>pg8000 Transaction Isolation Level</em></a></p>
 
1809
</div>
1770
1810
</div>
1771
1811
<div class="section" id="notice-logging">
1772
1812
<h3>NOTICE logging<a class="headerlink" href="#notice-logging" title="Permalink to this headline">¶</a></h3>
1787
1827
<li>Request the available HSTORE oids using <tt class="docutils literal"><span class="pre">psycopg2.extras.HstoreAdapter.get_oids()</span></tt>.
1788
1828
If this function returns a list of HSTORE identifiers, we then determine that
1789
1829
the <tt class="docutils literal"><span class="pre">HSTORE</span></tt> extension is present.</li>
1790
 
<li>If the <tt class="docutils literal"><span class="pre">use_native_hstore</span></tt> flag is at it&#8217;s default of <tt class="docutils literal"><span class="pre">True</span></tt>, and
 
1830
<li>If the <tt class="docutils literal"><span class="pre">use_native_hstore</span></tt> flag is at its default of <tt class="docutils literal"><span class="pre">True</span></tt>, and
1791
1831
we&#8217;ve detected that <tt class="docutils literal"><span class="pre">HSTORE</span></tt> oids are available, the
1792
1832
<tt class="docutils literal"><span class="pre">psycopg2.extensions.register_hstore()</span></tt> extension is invoked for all
1793
1833
connections.</li>
1828
1868
<div class="section" id="dialect-postgresql-pg8000-url">
1829
1869
<h3>DBAPI<a class="headerlink" href="#dialect-postgresql-pg8000-url" title="Permalink to this headline">¶</a></h3>
1830
1870
<p>Documentation and download information (if applicable) for pg8000 is available at:
1831
 
<a class="reference external" href="http://pybrary.net/pg8000/">http://pybrary.net/pg8000/</a></p>
 
1871
<a class="reference external" href="https://pythonhosted.org/pg8000/">https://pythonhosted.org/pg8000/</a></p>
1832
1872
</div>
1833
1873
<div class="section" id="dialect-postgresql-pg8000-connect">
1834
1874
<h3>Connecting<a class="headerlink" href="#dialect-postgresql-pg8000-connect" title="Permalink to this headline">¶</a></h3>
1838
1878
</div>
1839
1879
<div class="section" id="id3">
1840
1880
<h3>Unicode<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
1841
 
<p>pg8000 requires that the postgresql client encoding be
1842
 
configured in the postgresql.conf file in order to use encodings
1843
 
other than ascii. Set this value to the same value as the
1844
 
&#8220;encoding&#8221; parameter on create_engine(), usually &#8220;utf-8&#8221;.</p>
1845
 
</div>
1846
 
<div class="section" id="interval">
1847
 
<h3>Interval<a class="headerlink" href="#interval" title="Permalink to this headline">¶</a></h3>
1848
 
<p>Passing data from/to the Interval type is not supported as of
1849
 
yet.</p>
 
1881
<p>When communicating with the server, pg8000 uses the character set that the
 
1882
server asks it to use (the client encoding). By default the client encoding is
 
1883
the database&#8217;s character set (chosen when the database is created), but the
 
1884
client encoding can be changed in a number of ways (eg. setting CLIENT_ENCODING
 
1885
in postgresql.conf).</p>
 
1886
<p>Set the &#8220;encoding&#8221; parameter on create_engine(), to the same as the client
 
1887
encoding, usually &#8220;utf-8&#8221;.</p>
 
1888
</div>
 
1889
<div class="section" id="pg8000-transaction-isolation-level">
 
1890
<span id="pg8000-isolation-level"></span><h3>pg8000 Transaction Isolation Level<a class="headerlink" href="#pg8000-transaction-isolation-level" title="Permalink to this headline">¶</a></h3>
 
1891
<p>The pg8000 dialect offers the same isolation level settings as that
 
1892
of the <a class="reference internal" href="#psycopg2-isolation-level"><em>psycopg2</em></a> dialect:</p>
 
1893
<ul class="simple">
 
1894
<li><tt class="docutils literal"><span class="pre">READ</span> <span class="pre">COMMITTED</span></tt></li>
 
1895
<li><tt class="docutils literal"><span class="pre">READ</span> <span class="pre">UNCOMMITTED</span></tt></li>
 
1896
<li><tt class="docutils literal"><span class="pre">REPEATABLE</span> <span class="pre">READ</span></tt></li>
 
1897
<li><tt class="docutils literal"><span class="pre">SERIALIZABLE</span></tt></li>
 
1898
<li><tt class="docutils literal"><span class="pre">AUTOCOMMIT</span></tt></li>
 
1899
</ul>
 
1900
<div class="versionadded">
 
1901
<p><span>New in version 0.9.5: </span>support for AUTOCOMMIT isolation level when using
 
1902
pg8000.</p>
 
1903
</div>
 
1904
<div class="admonition seealso">
 
1905
<p class="first admonition-title">See also</p>
 
1906
<p><a class="reference internal" href="#postgresql-isolation-level"><em>Transaction Isolation Level</em></a></p>
 
1907
<p class="last"><a class="reference internal" href="#psycopg2-isolation-level"><em>Psycopg2 Transaction Isolation Level</em></a></p>
 
1908
</div>
1850
1909
</div>
1851
1910
</div>
1852
1911
<div class="section" id="module-sqlalchemy.dialects.postgresql.zxjdbc">