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
|
<!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>General PyGreSQL programming information — PyGreSQL 5.0 documentation</title>
<link rel="stylesheet" href="../_static/cloud.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygresql.css" type="text/css" />
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Noticia+Text|Open+Sans|Droid+Sans+Mono" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '5.0.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</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/jquery.cookie.js"></script>
<script type="text/javascript" src="../_static/cloud.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="top" title="PyGreSQL 5.0 documentation" href="index.html" />
<link rel="next" title="First Steps with PyGreSQL" href="tutorial.html" />
<link rel="prev" title="ChangeLog" href="changelog.html" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body role="document">
<div class="pageheader related" role="navigation" aria-label="related navigation">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a href="../download/index.html">Download</a></li>
<li><a href="index.html">Documentation</a></li>
<li><a href="../community/index.html">Community</a></li>
</ul>
<div class="logo">
<a href="../index.html">PyGreSQL</a>
</div>
</div>
</div>
<div class="relbar-top">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="tutorial.html" title="First Steps with PyGreSQL"
accesskey="N">next</a> </li>
<li class="right" >
<a href="changelog.html" title="ChangeLog"
accesskey="P">previous</a> </li>
<li><a href="index.html">PyGreSQL 5.0 documentation</a> »</li>
</ul>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="general-pygresql-programming-information">
<h1>General PyGreSQL programming information<a class="headerlink" href="#general-pygresql-programming-information" title="Permalink to this headline">ΒΆ</a></h1>
<p>PyGreSQL consists of two parts: the “classic” PyGreSQL interface
provided by the <a class="reference internal" href="pg/index.html#module-pg" title="pg"><code class="xref py py-mod docutils literal"><span class="pre">pg</span></code></a> module and the newer
DB-API 2.0 compliant interface provided by the <a class="reference internal" href="pgdb/index.html#module-pgdb" title="pgdb"><code class="xref py py-mod docutils literal"><span class="pre">pgdb</span></code></a> module.</p>
<p>If you use only the standard features of the DB-API 2.0 interface,
it will be easier to switch from PostgreSQL to another database
for which a DB-API 2.0 compliant interface exists.</p>
<p>The “classic” interface may be easier to use for beginners, and it
provides some higher-level and PostgreSQL specific convenience methods.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><strong>DB-API 2.0</strong> (Python Database API Specification v2.0)
is a specification for connecting to databases (not only PostGreSQL)
from Python that has been developed by the Python DB-SIG in 1999.
The authoritative programming information for the DB-API is <span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0249"><strong>PEP 0249</strong></a>.</p>
</div>
<p>Both Python modules utilize the same lower level C extension module that
serves as a wrapper for the C API to PostgreSQL that is available in form
of the so-called “libpq” library.</p>
<p>This means you must have the libpq library installed as a shared library
on your client computer, in a version that is supported by PyGreSQL.
Depending on the client platform, you may have to set environment variables
like <cite>PATH</cite> or <cite>LD_LIBRARY_PATH</cite> so that PyGreSQL can find the library.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Note that PyGreSQL is not thread-safe on the connection level. Therefore
we recommend using <a class="reference external" href="http://www.webwareforpython.org/DBUtils">DBUtils</a>
for multi-threaded environments, which supports both PyGreSQL interfaces.</p>
</div>
<p>Another option is using PyGreSQL indirectly as a database driver for the
high-level <a class="reference external" href="http://www.sqlalchemy.org/">SQLAlchemy</a> SQL toolkit and ORM,
which supports PyGreSQL starting with SQLAlchemy 1.1 and which provides a
way to use PyGreSQL in a multi-threaded environment using the concept of
“thread local storage”. Database URLs for PyGreSQL take this form:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="n">postgresql</span><span class="o">+</span><span class="n">pygresql</span><span class="p">:</span><span class="o">//</span><span class="n">username</span><span class="p">:</span><span class="n">password</span><span class="nd">@host</span><span class="p">:</span><span class="n">port</span><span class="o">/</span><span class="n">database</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html" title="contents/index">
<img class="logo" src="../_static/pygresql.png" alt="Logo"/>
</a></p>
<div class="sphinxprev">
<h4>Previous page</h4>
<p class="topless"><a href="changelog.html"
title="Previous page">← ChangeLog</a></p>
</div>
<div class="sphinxnext">
<h4>Next page</h4>
<p class="topless"><a href="tutorial.html"
title="Next page">→ First Steps with PyGreSQL</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/contents/general.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="relbar-bottom">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="tutorial.html" title="First Steps with PyGreSQL"
>next</a> </li>
<li class="right" >
<a href="changelog.html" title="ChangeLog"
>previous</a> </li>
<li><a href="index.html">PyGreSQL 5.0 documentation</a> »</li>
</ul>
</div>
</div>
<div class="footer" role="contentinfo">
© <a href="../copyright.html">Copyright</a> 2016, The PyGreSQL team.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.1.
</div>
<!-- cloud_sptheme 1.4 -->
</body>
</html>
|