Merge lp:~groldster/ubuntu/maverick/psycopg2/merge-611040 into lp:ubuntu/maverick/psycopg2

Proposed by Mikhail Turov
Status: Merged
Merged at revision: 14
Proposed branch: lp:~groldster/ubuntu/maverick/psycopg2/merge-611040
Merge into: lp:ubuntu/maverick/psycopg2
Diff against target: 35827 lines (+30180/-2336)
173 files modified
ChangeLog (+131/-0)
LICENSE (+29/-35)
MANIFEST (+76/-6)
MANIFEST.in (+6/-3)
NEWS-2.0 (+586/-0)
NEWS-2.2 (+39/-0)
PKG-INFO (+3/-3)
README (+13/-9)
ZPsycopgDA/DA.py (+17/-19)
ZPsycopgDA/__init__.py (+14/-16)
ZPsycopgDA/db.py (+17/-19)
ZPsycopgDA/pool.py (+17/-19)
debian/changelog (+30/-7)
debian/control (+3/-12)
debian/rules (+0/-2)
debian/source/format (+1/-0)
doc/COPYING (+676/-0)
doc/COPYING.LESSER (+165/-0)
doc/Makefile (+23/-0)
doc/README (+42/-0)
doc/TODO (+0/-33)
doc/api-screen.css (+0/-138)
doc/async.txt (+0/-67)
doc/extensions.rst (+0/-260)
doc/html/.buildinfo (+4/-0)
doc/html/_sources/advanced.txt (+450/-0)
doc/html/_sources/connection.txt (+365/-0)
doc/html/_sources/cursor.txt (+473/-0)
doc/html/_sources/errorcodes.txt (+76/-0)
doc/html/_sources/extensions.txt (+565/-0)
doc/html/_sources/extras.txt (+165/-0)
doc/html/_sources/faq.txt (+139/-0)
doc/html/_sources/index.txt (+62/-0)
doc/html/_sources/module.txt (+316/-0)
doc/html/_sources/pool.txt (+62/-0)
doc/html/_sources/tz.txt (+16/-0)
doc/html/_sources/usage.txt (+510/-0)
doc/html/_static/basic.css (+417/-0)
doc/html/_static/default.css (+230/-0)
doc/html/_static/doctools.js (+232/-0)
doc/html/_static/jquery.js (+6240/-0)
doc/html/_static/psycopg.css (+28/-0)
doc/html/_static/pygments.css (+61/-0)
doc/html/_static/searchtools.js (+467/-0)
doc/html/advanced.html (+434/-0)
doc/html/connection.html (+420/-0)
doc/html/cursor.html (+534/-0)
doc/html/errorcodes.html (+168/-0)
doc/html/extensions.html (+743/-0)
doc/html/extras.html (+354/-0)
doc/html/faq.html (+231/-0)
doc/html/genindex.html (+782/-0)
doc/html/index.html (+178/-0)
doc/html/modindex.html (+120/-0)
doc/html/module.html (+414/-0)
doc/html/objects.inv (+217/-0)
doc/html/pool.html (+181/-0)
doc/html/search.html (+97/-0)
doc/html/searchindex.js (+1/-0)
doc/html/tz.html (+132/-0)
doc/html/usage.html (+506/-0)
doc/pep-0249.txt (+1005/-0)
doc/psycopg2.txt (+2820/-0)
doc/src/Makefile (+99/-0)
doc/src/_static/psycopg.css (+28/-0)
doc/src/advanced.rst (+450/-0)
doc/src/conf.py (+257/-0)
doc/src/connection.rst (+365/-0)
doc/src/cursor.rst (+473/-0)
doc/src/errorcodes.rst (+76/-0)
doc/src/extensions.rst (+565/-0)
doc/src/extras.rst (+165/-0)
doc/src/faq.rst (+139/-0)
doc/src/index.rst (+62/-0)
doc/src/module.rst (+316/-0)
doc/src/pool.rst (+62/-0)
doc/src/tools/lib/dbapi_extension.py (+52/-0)
doc/src/tools/lib/sql_role.py (+21/-0)
doc/src/tools/stitch_text.py (+56/-0)
doc/src/tz.rst (+16/-0)
doc/src/usage.rst (+510/-0)
examples/binary.py (+11/-11)
examples/copy_from.py (+0/-1)
examples/copy_to.py (+0/-1)
examples/cursor.py (+11/-11)
examples/dict.py (+11/-11)
examples/dt.py (+11/-11)
examples/encoding.py (+12/-12)
examples/fetch.py (+11/-12)
examples/lastrowid.py (+11/-11)
examples/mogrify.py (+11/-11)
examples/myfirstrecipe.py (+26/-22)
examples/notify.py (+15/-14)
examples/simple.py (+12/-11)
examples/threads.py (+11/-11)
examples/typecast.py (+11/-11)
examples/tz.py (+11/-11)
examples/usercast.py (+11/-11)
lib/__init__.py (+28/-13)
lib/errorcodes.py (+103/-60)
lib/extensions.py (+39/-17)
lib/extras.py (+88/-44)
lib/pool.py (+21/-13)
lib/psycopg1.py (+19/-11)
lib/tz.py (+29/-16)
psycopg/adapter_asis.c (+19/-15)
psycopg/adapter_asis.h (+18/-14)
psycopg/adapter_binary.c (+20/-16)
psycopg/adapter_binary.h (+18/-14)
psycopg/adapter_datetime.c (+45/-21)
psycopg/adapter_datetime.h (+18/-14)
psycopg/adapter_list.c (+18/-14)
psycopg/adapter_list.h (+18/-14)
psycopg/adapter_mxdatetime.c (+25/-21)
psycopg/adapter_mxdatetime.h (+18/-14)
psycopg/adapter_pboolean.c (+18/-14)
psycopg/adapter_pboolean.h (+18/-14)
psycopg/adapter_pdecimal.c (+268/-0)
psycopg/adapter_pdecimal.h (+58/-0)
psycopg/adapter_pfloat.c (+19/-15)
psycopg/adapter_pfloat.h (+18/-14)
psycopg/adapter_qstring.c (+18/-14)
psycopg/adapter_qstring.h (+18/-14)
psycopg/config.h (+18/-14)
psycopg/connection.h (+58/-19)
psycopg/connection_int.c (+544/-117)
psycopg/connection_type.c (+138/-31)
psycopg/cursor.h (+32/-18)
psycopg/cursor_int.c (+18/-14)
psycopg/cursor_type.c (+46/-126)
psycopg/green.c (+198/-0)
psycopg/green.h (+75/-0)
psycopg/lobject.h (+19/-14)
psycopg/lobject_int.c (+52/-20)
psycopg/lobject_type.c (+48/-14)
psycopg/microprotocols.c (+21/-15)
psycopg/microprotocols.h (+18/-14)
psycopg/microprotocols_proto.c (+18/-14)
psycopg/microprotocols_proto.h (+18/-14)
psycopg/pqpath.c (+295/-150)
psycopg/pqpath.h (+28/-17)
psycopg/psycopg.h (+18/-14)
psycopg/psycopgmodule.c (+60/-27)
psycopg/python.h (+19/-14)
psycopg/typecast.c (+51/-16)
psycopg/typecast.h (+18/-14)
psycopg/typecast_array.c (+21/-17)
psycopg/typecast_basic.c (+29/-19)
psycopg/typecast_binary.c (+21/-17)
psycopg/typecast_binary.h (+18/-14)
psycopg/typecast_datetime.c (+21/-17)
psycopg/typecast_mxdatetime.c (+21/-17)
psycopg/utils.c (+21/-0)
psycopg2da/adapter.py (+18/-25)
psycopg2da/tests.py (+19/-13)
scripts/ext2html.py (+0/-169)
scripts/make_errorcodes.py (+115/-0)
scripts/makedocs.py (+0/-15)
setup.py (+29/-22)
tests/__init__.py (+23/-1)
tests/bugX000.py (+1/-0)
tests/bug_gc.py (+31/-0)
tests/extras_dictcursor.py (+12/-11)
tests/test_async.py (+410/-0)
tests/test_connection.py (+29/-4)
tests/test_copy.py (+104/-0)
tests/test_dates.py (+128/-3)
tests/test_green.py (+76/-0)
tests/test_lobject.py (+68/-0)
tests/test_notify.py (+100/-0)
tests/test_transaction.py (+2/-0)
tests/types_basic.py (+52/-18)
tests/types_extras.py (+21/-11)
To merge this branch: bzr merge lp:~groldster/ubuntu/maverick/psycopg2/merge-611040
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+31203@code.launchpad.net

Description of the change

merge psycopg2 2.2.1-1 (main) from Debian unstable (main)

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Good work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2009-10-12 06:50:00 +0000
+++ ChangeLog 2010-07-28 20:35:51 +0000
@@ -1,3 +1,134 @@
12010-05-17 Federico Di Gregorio <fog@initd.org>
2
3 * Release 2.2.1.
4
5 * Builds again on Windows.
6
72010-05-16 Federico Di Gregorio <fog@initd.org>
8
9 * Release 2.2.0.
10
112010-05-15 Federico Di Gregorio <fog@initd.org>
12
13 * typecast.c: Fixed problem related to receiving None from Python
14 when a string was expected.
15
162010-05-07 Daniele Varrazzo <daniele.varrazzo@gmail.com>
17
18 * psycopg/adapter_datetime.c: Fixed TimestampFromTicks for second
19 values > 59.5.
20
21 Bug reported and fixed by Jozsef Szalay on 2010-05-06 at 14:11:59.999920.
22
23 * psycopg/adapter_datetime.c: Fixed same bug for TimeFromTicks.
24
252010-05-04 Daniele Varrazzo <daniele.varrazzo@gmail.com>
26
27 * Added typecasters for arrays of specific MX/Py time-related types.
28
29 * psycopg/adapter_[mx]datetime.c: Explicit cast of the SQL representation
30 of time-related objects.
31
322010-05-03 Daniele Varrazzo <daniele.varrazzo@gmail.com>
33
34 * psycopg/adapter_binary.c: Adapt buffer objects using an explicit cast on
35 the string literal (bug reported by Peter Eisentraut)
36
372010-04-20 Daniele Varrazzo <daniele.varrazzo@gmail.com>
38
39 * lib/pqpath.c: Fixed reference leak in notify reception.
40
41 * Notifies are collected if available after every query execution.
42
432010-04-13 Daniele Varrazzo <daniele.varrazzo@gmail.com>
44
45 * lib/extensions.py: DECIMAL typecaster imported from _psycopg.
46
47 * lib/extensions.py: PY* and MX* time typecaster imported from _psycopg.
48
492010-04-11 Daniele Varrazzo <daniele.varrazzo@gmail.com>
50
51 * psycopg/connection_type.c: Correctly parse keywords in connect().
52
532010-04-07 Daniele Varrazzo <daniele.varrazzo@gmail.com>
54
55 * psycopg/pqpath.c: Ensure running COPY in blocking mode.
56
57 * psycopg/pqpath.c: Free the GIL in blocking operations in V2 COPY FROM.
58
59 * psycopg/pqpath.c: Evaluate Python objects only once outside the COPY I/O
60 loops.
61
622010-04-05 Federico Di Gregorio <fog@initd.org>
63
64 * Fixed problem with asynchronous NOTIFYs.
65
66 * Integrated async pacthes from Jan's git tree.
67
682010-03-13 Federico Di Gregorio <fog@initd.org>
69
70 * Release 2.0.14.
71
722010-03-11 Federico Di Gregorio <fog@initd.org>
73
74 * setup.py: one-liner from Devrim GÜNDÜZ to build with PostgreSQL
75 alpha.
76
772010-02-28 Federico Di Gregorio <fog@initd.org>
78
79 * psycopg/adapt_decimal.c: Python 2.4 decimal type does not support
80 .isfinite() and two different calls to ._isinfinity() and ._isnan() are
81 required. This fixes both a test failure and a segfault.
82
832010-02-15 Federico Di Gregorio <fog@initd.org>
84
85 * Added new Decimal adapter that correctly converts NaN and infinity
86 to PostgreSQL NaN numeric values. Also added tests.
87
882010-02-15 Daniele Varrazzo <daniele.varrazzo@gmail.com>
89
90 * lib/errorcodes.py: Updated to PostgreSQL 8.4; added lookup() function.
91
922010-02-12 Daniele Varrazzo <daniele.varrazzo@gmail.com>
93
94 * Stop the loop variable used to create __all__ leaking in the module.
95
96 * Fixed Inet constructor.
97
98 * Fixed docstring for 'QueryCanceledError' exception.
99
1002010-02-10 Federico Di Gregorio <fog@initd.org>
101
102 * lib/extensions.py: Binary was not imported from _psycopg; now it is
103
104 * lib/__init__: SQL_IN adapter is now automatically registered.
105
106 * ZPsycopgDA/db.py: removed logging debug calls; psycopg does
107 not depend on the logger module.
108
1092010-02-12 Federico Di Gregorio <fog@initd.org>
110
111 * License migration: psycopg2 is now LGPL3 + OpenSSL exception.
112
113 * TODO file was never updated so lets remove it.
114
1152010-02-10 Federico Di Gregorio <fog@initd.org>
116
117 * lib/extras.py: fixed register_tstz_w_secs() error as reported by
118 Karsten Hilbert.
119
1202009-11-25 Federico Di Gregorio <fog@initd.org>
121
122 * psycopg/microprotocols.c: "can't adapt" message now includes full
123 type information (adapted patch from Eric Chamberlain).
124
125 * tests/types_basic.py: fixed test broken by float precision fix.
126
1272009-11-09 Federico Di Gregorio <fog@initd.org>
128
129 * psycopg/adapter_pfloat.c: applied patch from Remy Blankto fix float
130 loss of precision.
131
12009-10-04 Federico Di Gregorio <fog@initd.org>1322009-10-04 Federico Di Gregorio <fog@initd.org>
2133
3 * Release 2.0.13.134 * Release 2.0.13.
4135
=== modified file 'LICENSE'
--- LICENSE 2006-08-09 10:28:30 +0000
+++ LICENSE 2010-07-28 20:35:51 +0000
@@ -1,24 +1,32 @@
1psycopg and the GPL1psycopg2 and the LGPL
2===================2=====================
33
4psycopg is free software; you can redistribute it and/or modify4psycopg2 is free software: you can redistribute it and/or modify it
5it under the terms of the GNU General Public License as published by5under the terms of the GNU Lesser General Public License as published
6the Free Software Foundation; either version 2 of the License, or6by the Free Software Foundation, either version 3 of the License, or
7(at your option) any later version. See file COPYING for details.7(at your option) any later version.
88
9As a special exception, specific permission is granted for the GPLed9psycopg2 is distributed in the hope that it will be useful, but WITHOUT
10code in this distribition to be linked to OpenSSL and PostgreSQL libpq10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11without invoking GPL clause 2(b).11FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
1212License for more details.
13Note that the GPL was chosen to avoid proprietary adapters based on13
14psycopg code. Using psycopg in a proprietary product (even bundling14In addition, as a special exception, the copyright holders give
15psycopg with the proprietary product) is fine as long as:15permission to link this program with the OpenSSL library (or with
1616modified versions of OpenSSL that use the same license as OpenSSL),
17 1. psycopg is called from Python only using only the provided API17and distribute linked combinations including the two.
18 (i.e., no linking with C code and no C modules based on it); and18
1919You must obey the GNU Lesser General Public License in all respects for
20 2. all the other points of the GPL are respected (you offer a copy20all of the code used other than OpenSSL. If you modify file(s) with this
21 of psycopg's source code, and so on.)21exception, you may extend this exception to your version of the file(s),
22but you are not obligated to do so. If you do not wish to do so, delete
23this exception statement from your version. If you delete this exception
24statement from all source files in the program, then also delete it here.
25
26You should have received a copy of the GNU Lesser General Public License
27along with psycopg2 (see the doc/ directory.)
28If not, see <http://www.gnu.org/licenses/>.
29
2230
23Alternative licenses31Alternative licenses
24====================32====================
@@ -44,17 +52,3 @@
44 be misrepresented as being the original software.52 be misrepresented as being the original software.
45 53
46 3. This notice may not be removed or altered from any source distribution.54 3. This notice may not be removed or altered from any source distribution.
47
48psycopg is distributed in the hope that it will be useful,
49but WITHOUT ANY WARRANTY; without even the implied warranty of
50MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51GNU General Public License for more details.
52
53Proprietary licenses
54====================
55
56A non-exclusive license is available for companies that want to include
57psycopg in their proprietary products without respecting the spirit of the
58GPL. The price of the license is one day of development done by the author,
59at the consulting fee he applies to his usual customers at the day of the
60request.
6155
=== modified file 'MANIFEST'
--- MANIFEST 2009-10-12 06:50:00 +0000
+++ MANIFEST 2010-07-28 20:35:51 +0000
@@ -4,6 +4,8 @@
4LICENSE4LICENSE
5MANIFEST5MANIFEST
6MANIFEST.in6MANIFEST.in
7NEWS-2.0
8NEWS-2.2
7README9README
8setup.cfg10setup.cfg
9setup.py11setup.py
@@ -37,13 +39,73 @@
37debian/rules39debian/rules
38debian/watch40debian/watch
39debian/zope-psycopgda2.dzproduct41debian/zope-psycopgda2.dzproduct
42doc/COPYING
43doc/COPYING.LESSER
40doc/ChangeLog-1.x44doc/ChangeLog-1.x
41doc/HACKING45doc/HACKING
46doc/Makefile
47doc/README
42doc/SUCCESS48doc/SUCCESS
43doc/TODO49doc/pep-0249.txt
44doc/api-screen.css50doc/psycopg2.txt
45doc/async.txt51doc/html/.buildinfo
46doc/extensions.rst52doc/html/advanced.html
53doc/html/connection.html
54doc/html/cursor.html
55doc/html/errorcodes.html
56doc/html/extensions.html
57doc/html/extras.html
58doc/html/faq.html
59doc/html/genindex.html
60doc/html/index.html
61doc/html/modindex.html
62doc/html/module.html
63doc/html/objects.inv
64doc/html/pool.html
65doc/html/search.html
66doc/html/searchindex.js
67doc/html/tz.html
68doc/html/usage.html
69doc/html/_sources/advanced.txt
70doc/html/_sources/connection.txt
71doc/html/_sources/cursor.txt
72doc/html/_sources/errorcodes.txt
73doc/html/_sources/extensions.txt
74doc/html/_sources/extras.txt
75doc/html/_sources/faq.txt
76doc/html/_sources/index.txt
77doc/html/_sources/module.txt
78doc/html/_sources/pool.txt
79doc/html/_sources/tz.txt
80doc/html/_sources/usage.txt
81doc/html/_static/basic.css
82doc/html/_static/default.css
83doc/html/_static/doctools.js
84doc/html/_static/file.png
85doc/html/_static/jquery.js
86doc/html/_static/minus.png
87doc/html/_static/plus.png
88doc/html/_static/psycopg.css
89doc/html/_static/pygments.css
90doc/html/_static/searchtools.js
91doc/src/Makefile
92doc/src/advanced.rst
93doc/src/conf.py
94doc/src/connection.rst
95doc/src/cursor.rst
96doc/src/errorcodes.rst
97doc/src/extensions.rst
98doc/src/extras.rst
99doc/src/faq.rst
100doc/src/index.rst
101doc/src/module.rst
102doc/src/pool.rst
103doc/src/tz.rst
104doc/src/usage.rst
105doc/src/_static/psycopg.css
106doc/src/tools/stitch_text.py
107doc/src/tools/lib/dbapi_extension.py
108doc/src/tools/lib/sql_role.py
47examples/binary.py109examples/binary.py
48examples/copy_from.py110examples/copy_from.py
49examples/copy_to.py111examples/copy_to.py
@@ -84,6 +146,8 @@
84psycopg/adapter_mxdatetime.h146psycopg/adapter_mxdatetime.h
85psycopg/adapter_pboolean.c147psycopg/adapter_pboolean.c
86psycopg/adapter_pboolean.h148psycopg/adapter_pboolean.h
149psycopg/adapter_pdecimal.c
150psycopg/adapter_pdecimal.h
87psycopg/adapter_pfloat.c151psycopg/adapter_pfloat.c
88psycopg/adapter_pfloat.h152psycopg/adapter_pfloat.h
89psycopg/adapter_qstring.c153psycopg/adapter_qstring.c
@@ -95,6 +159,8 @@
95psycopg/cursor.h159psycopg/cursor.h
96psycopg/cursor_int.c160psycopg/cursor_int.c
97psycopg/cursor_type.c161psycopg/cursor_type.c
162psycopg/green.c
163psycopg/green.h
98psycopg/lobject.h164psycopg/lobject.h
99psycopg/lobject_int.c165psycopg/lobject_int.c
100psycopg/lobject_type.c166psycopg/lobject_type.c
@@ -129,16 +195,20 @@
129psycopg2da/psycopg2da-configure.zcml195psycopg2da/psycopg2da-configure.zcml
130psycopg2da/tests.py196psycopg2da/tests.py
131scripts/buildtypes.py197scripts/buildtypes.py
132scripts/ext2html.py198scripts/make_errorcodes.py
133scripts/makedocs.py
134scripts/maketypes.sh199scripts/maketypes.sh
135tests/__init__.py200tests/__init__.py
136tests/bugX000.py201tests/bugX000.py
202tests/bug_gc.py
137tests/dbapi20.py203tests/dbapi20.py
138tests/extras_dictcursor.py204tests/extras_dictcursor.py
205tests/test_async.py
139tests/test_connection.py206tests/test_connection.py
207tests/test_copy.py
140tests/test_dates.py208tests/test_dates.py
209tests/test_green.py
141tests/test_lobject.py210tests/test_lobject.py
211tests/test_notify.py
142tests/test_psycopg2_dbapi20.py212tests/test_psycopg2_dbapi20.py
143tests/test_quote.py213tests/test_quote.py
144tests/test_transaction.py214tests/test_transaction.py
145215
=== modified file 'MANIFEST.in'
--- MANIFEST.in 2007-06-18 22:44:12 +0000
+++ MANIFEST.in 2010-07-28 20:35:51 +0000
@@ -5,9 +5,12 @@
5recursive-include psycopg2da * 5recursive-include psycopg2da *
6recursive-include examples *.py somehackers.jpg whereareyou.jpg6recursive-include examples *.py somehackers.jpg whereareyou.jpg
7recursive-include debian *7recursive-include debian *
8recursive-include doc TODO HACKING SUCCESS ChangeLog-1.x async.txt8recursive-include doc README TODO HACKING SUCCESS COPYING* ChangeLog-1.x pep-0249.txt
9recursive-include doc *.rst *.css *.html9recursive-include doc *.txt *.html *.css *.js Makefile
10recursive-include doc/src *.rst *.py *.css Makefile
11recursive-include doc/html *
12prune doc/src/_build
10recursive-include scripts *.py *.sh13recursive-include scripts *.py *.sh
11include scripts/maketypes.sh scripts/buildtypes.py14include scripts/maketypes.sh scripts/buildtypes.py
12include AUTHORS README INSTALL LICENSE ChangeLog 15include AUTHORS README INSTALL LICENSE NEWS-2.0 NEWS-2.2 ChangeLog
13include PKG-INFO MANIFEST.in MANIFEST setup.py setup.cfg16include PKG-INFO MANIFEST.in MANIFEST setup.py setup.cfg
1417
=== added file 'NEWS-2.0'
--- NEWS-2.0 1970-01-01 00:00:00 +0000
+++ NEWS-2.0 2010-07-28 20:35:51 +0000
@@ -0,0 +1,586 @@
1What's new in psycopg 2.0.14
2----------------------------
3
4* New features:
5 - Support for adapting tuples to PostgreSQL arrays is now enabled by
6 default and does not require importing psycopg2.extensions anymore.
7 - "can't adapt" error message now includes full type information.
8 - Thank to Daniele Varrazzo (piro) psycopg2's source package now includes
9 full documentation in HTML and plain text format.
10
11* Bug fixes:
12 - No loss of precision when using floats anymore.
13 - decimal.Decimal "nan" and "infinity" correctly converted to PostgreSQL
14 numeric NaN values (note that PostgreSQL numeric type does not support
15 infinity but just NaNs.)
16 - psycopg2.extensions now includes Binary.
17
18* It seems we're good citizens of the free software ecosystem and that big
19 big big companies and people ranting on the pgsql-hackers mailing list
20 we'll now not dislike us. *g* (See LICENSE file for the details.)
21
22
23What's new in psycopg 2.0.13
24----------------------------
25
26* New features:
27 - Support for UUID arrays.
28 - It is now possible to build psycopg linking to a static libpq
29 library.
30
31* Bug fixes:
32 - Fixed a deadlock related to using the same connection with
33 multiple cursors from different threads.
34 - Builds again with MSVC.
35
36
37What's new in psycopg 2.0.12
38----------------------------
39
40* New features:
41 - The connection object now has a reset() method that can be used to
42 reset the connection to its default state.
43
44* Bug fixes:
45 - copy_to() and copy_from() now accept a much larger number of columns.
46 - Fixed PostgreSQL version detection.
47 - Fixed ZPsycopgDA version check.
48 - Fixed regression in ZPsycopgDA that made it behave wrongly when
49 receiving serialization errors: now the query is re-issued as it
50 should be by propagating the correct exception to Zope.
51 - Writing "large" large objects should now work.
52
53
54What's new in psycopg 2.0.11
55----------------------------
56
57* New features:
58 - DictRow and RealDictRow now use less memory. If you inherit on them
59 remember to set __slots__ for your new attributes or be prepare to
60 go back to old memory usage.
61
62* Bug fixes:
63 - Fixed exeception in setup.py.
64 - More robust detection of PostgreSQL development versions.
65 - Fixed exception in RealDictCursor, introduced in 2.0.10.
66
67
68What's new in psycopg 2.0.10
69----------------------------
70
71* New features:
72 - A specialized type-caster that can parse time zones with seconds is
73 now available. Note that after enabling it (see extras.py) "wrong"
74 time zones will be parsed without raising an exception but the
75 result will be rounded.
76 - DictCursor can be used as a named cursor.
77 - DictRow now implements more dict methods.
78 - The connection object now expose PostgreSQL server version as the
79 .server_version attribute and the protocol version used as
80 .protocol_version.
81 - The connection object has a .get_parameter_status() methods that
82 can be used to obtain useful information from the server.
83
84* Bug fixes:
85 - None is now correctly always adapted to NULL.
86 - Two double memory free errors provoked by multithreading and
87 garbage collection are now fixed.
88 - Fixed usage of internal Python code in the notice processor; this
89 should fix segfaults when receiving a lot of notices in
90 multithreaded programs.
91 - Should build again on MSVC and Solaris.
92 - Should build with development versions of PostgreSQL (ones with
93 -devel version string.)
94 - Fixed some tests that failed even when psycopg was right.
95
96
97What's new in psycopg 2.0.9
98---------------------------
99
100* New features:
101 - "import psycopg2.extras" to get some support for handling times
102 and timestamps with seconds in the time zone offset.
103 - DictCursors can now be used as named cursors.
104
105* Bug fixes:
106 - register_type() now accept an explicit None as its second parameter.
107 - psycopg2 should build again on MSVC and Solaris.
108
109
110What's new in psycopg 2.0.9
111---------------------------
112
113* New features:
114 - COPY TO/COPY FROM queries now can be of any size and psycopg will
115 correctly quote separators.
116 - float values Inf and NaN are now correctly handled and can
117 round-trip to the database.
118 - executemany() now return the numer of total INSERTed or UPDATEd
119 rows. Note that, as it has always been, executemany() should not
120 be used to execute multiple SELECT statements and while it will
121 execute the statements without any problem, it will return the
122 wrong value.
123 - copy_from() and copy_to() can now use quoted separators.
124 - "import psycopg2.extras" to get UUID support.
125
126* Bug fixes:
127 - register_type() now works on connection and cursor subclasses.
128 - fixed a memory leak when using lobjects.
129
130
131What's new in psycopg 2.0.8
132---------------------------
133
134* New features:
135 - The connection object now has a get_backend_pid() method that
136 returns the current PostgreSQL connection backend process PID.
137 - The PostgreSQL large object API has been exposed through the
138 Cursor.lobject() method.
139
140* Bug fixes:
141 - Some fixes to ZPsycopgDA have been merged from the Debian package.
142 - A memory leak was fixed in Cursor.executemany().
143 - A double free was fixed in pq_complete_error(), that caused crashes
144 under some error conditions.
145
146What's new in psycopg 2.0.7
147---------------------------
148
149* Improved error handling:
150 - All instances of psycopg2.Error subclasses now have pgerror,
151 pgcode and cursor attributes. They will be set to None if no
152 value is available.
153 - Exception classes are now chosen based on the SQLSTATE value from
154 the result. (#184)
155 - The commit() and rollback() methods now set the pgerror and pgcode
156 attributes on exceptions. (#152)
157 - errors from commit() and rollback() are no longer considered
158 fatal. (#194)
159 - If a disconnect is detected during execute(), an exception will be
160 raised at that point rather than resulting in "ProgrammingError:
161 no results to fetch" later on. (#186)
162
163* Better PostgreSQL compatibility:
164 - If the server uses standard_conforming_strings, perform
165 appropriate quoting.
166 - BC dates are now handled if psycopg is compiled with mxDateTime
167 support. If using datetime, an appropriate ValueError is
168 raised. (#203)
169
170* Other bug fixes:
171 - If multiple sub-interpreters are in use, do not share the Decimal
172 type between them. (#192)
173 - Buffer objects obtained from psycopg are now accepted by psycopg
174 too, without segfaulting. (#209)
175 - A few small changes were made to improve DB-API compatibility.
176 All the dbapi20 tests now pass.
177
178* Miscellaneous:
179 - The PSYCOPG_DISPLAY_SIZE option is now off by default. This means
180 that display size will always be set to "None" in
181 cursor.description. Calculating the display size was expensive,
182 and infrequently used so this should improve performance.
183 - New QueryCanceledError and TransactionRollbackError exceptions
184 have been added to the psycopg2.extensions module. They can be
185 used to detect statement timeouts and deadlocks respectively.
186 - Cursor objects now have a "closed" attribute. (#164)
187 - If psycopg has been built with debug support, it is now necessary
188 to set the PSYCOPG_DEBUG environment variable to turn on debug
189 spew.
190
191What's new in psycopg 2.0.6
192---------------------------
193
194* Better support for PostgreSQL, Python and win32:
195 - full support for PostgreSQL 8.2, including NULLs in arrays
196 - support for almost all existing PostgreSQL encodings
197 - full list of PostgreSQL error codes available by importing the
198 psycopg2.errorcodes module
199 - full support for Python 2.5 and 64 bit architectures
200 - better build support on win32 platform
201
202* Support for per-connection type-casters (used by ZPsycopgDA too, this
203 fixes a long standing bug that made different connections use a random
204 set of date/time type-casters instead of the configured one.)
205
206* Better management of times and dates both from Python and in Zope.
207
208* copy_to and copy_from now take an extra "columns" parameter.
209
210* Python tuples are now adapted to SQL sequences that can be used with
211 the "IN" operator by default if the psycopg2.extensions module is
212 imported (i.e., the SQL_IN adapter was moved from extras to extensions.)
213
214* Fixed some small buglets and build glitches:
215 - removed double mutex destroy
216 - removed all non-constant initializers
217 - fixed PyObject_HEAD declarations to avoid memory corruption
218 on 64 bit architectures
219 - fixed several Python API calls to work on 64 bit architectures
220 - applied compatibility macros from PEP 353
221 - now using more than one argument format raise an error instead of
222 a segfault
223
224What's new in psycopg 2.0.5.1
225­----------------------------
226
227* Now it really, really builds on MSVC and older gcc versions.
228
229What's new in psycopg 2.0.5
230­--------------------------
231
232* Fixed various buglets such as:
233 - segfault when passing an empty string to Binary()
234 - segfault on null queries
235 - segfault and bad keyword naming in .executemany()
236 - OperationalError in connection objects was always None
237
238* Various changes to ZPsycopgDA to make it more zope2.9-ish.
239
240* connect() now accept both integers and strings as port parameter
241
242What's new in psycopg 2.0.4
243---------------------------
244
245* Fixed float conversion bug introduced in 2.0.3.
246
247What's new in psycopg 2.0.3
248---------------------------
249
250* Fixed various buglets and a memory leak (see ChangeLog for details)
251
252What's new in psycopg 2.0.2
253---------------------------
254
255* Fixed a bug in array typecasting that sometimes made psycopg forget about
256 the last element in the array.
257
258* Fixed some minor buglets in string memory allocations.
259
260* Builds again with compilers different from gcc (#warning about PostgreSQL
261 version is issued only if __GCC__ is defined.)
262
263What's new in psycopg 2.0.1
264---------------------------
265
266* ZPsycopgDA now actually loads.
267
268What's new in psycopg 2.0
269-------------------------
270
271* Fixed handle leak on win32.
272
273* If available the new "safe" encoding functions of libpq are used.
274
275* django and tinyerp people, please switch to psycopg 2 _without_
276 using a psycopg 1 compatibility layer (this release was anticipated
277 so that you all stop grumbling about psycopg 2 is still in beta.. :)
278
279What's new in psycopg 2.0 beta 7
280--------------------------------
281
282* Ironed out last problems with times and date (should be quite solid now.)
283
284* Fixed problems with some arrays.
285
286* Slightly better ZPsycopgDA (no more double connection objects in the menu
287 and other minor fixes.)
288
289* ProgrammingError exceptions now have three extra attributes: .cursor
290 (it is possible to access the query that caused the exception using
291 error.cursor.query), .pgerror and .pgcode (PostgreSQL original error
292 text and code.)
293
294* The build system uses pg_config when available.
295
296* Documentation in the doc/ directory! (With many kudos to piro.)
297
298What's new in psycopg 2.0 beta 6
299--------------------------------
300
301* Support for named cursors (see examples/fetch.py).
302
303* Safer parsing of time intervals.
304
305* Better parsing of times and dates, no more locale problems.
306
307* Should now play well with py2exe and similar tools.
308
309* The "decimal" module is now used if available under Python 2.3.
310
311What's new in psycopg 2.0 beta 5
312--------------------------------
313
314* Fixed all known bugs.
315
316* The initial isolation level is now read from the server and
317 .set_isolation_level() now takes values defined in psycopg2.extensions.
318
319* .callproc() implemented as a SELECT of the given procedure.
320
321* Better docstrings for a few functions/methods.
322
323* Some time-related functions like psycopg2.TimeFromTicks() now take the
324 local timezone into account. Also a tzinfo object (as per datetime module
325 specifications) can be passed to the psycopg2.Time and psycopg2.Datetime
326 constructors.
327
328* All classes have been renamed to exist in the psycopg2._psycopg module,
329 to fix problems with automatic documentation generators like epydoc.
330
331* NOTIFY is correctly trapped (see examples/notify.py for example code.)
332
333What's new in psycopg 2.0 beta 4
334--------------------------------
335
336* psycopg module is now named psycopg2.
337
338* No more segfaults when a UNICODE query can't be converted to the
339 backend encoding.
340
341* No more segfaults on empty queries.
342
343* psycopg2.connect() now takes an integer for the port keyword parameter.
344
345* "python setup.py bdist_rpm" now works.
346
347* Fixed lots of small bugs, see ChangeLog for details.
348
349What's new in psycopg 2.0 beta 3
350--------------------------------
351
352* ZPsycopgDA now works (except table browsing.)
353
354* psycopg build again on Python 2.2.
355
356What's new in psycopg 2.0 beta 2
357--------------------------------
358
359* Fixed ZPsycopgDA version check (ZPsycopgDA can now be imported in
360 Zope.)
361
362* psycopg.extras.DictRow works even after a new query on the generating
363 cursor.
364
365* Better setup.py for win32 (should build with MSCV or mingw.)
366
367* Generic fixed and memory leaks plugs.
368
369What's new in psycopg 2.0 beta 1
370--------------------------------
371
372* Officially in beta (i.e., no new features will be added.)
373
374* Array support: list objects can be passed as bound variables and are
375 correctly returned for array columns.
376
377* Added the psycopg.psycopg1 compatibility module (if you want instant
378 psycopg 1 compatibility just "from psycopg import psycopg1 as psycopg".)
379
380* Complete support for BYTEA columns and buffer objects.
381
382* Added error codes to error messages.
383
384* The AsIs adapter is now exported by default (also Decimal objects are
385 adapted using the AsIs adapter (when str() is called on them they
386 already format themselves using the right precision and scale.)
387
388* The connect() function now takes "connection_factory" instead of
389 "factory" as keyword argument.
390
391* New setup.py code to build on win32 using mingw and better error
392 messages on missing datetime headers,
393
394* Internal changes that allow much better user-defined type casters.
395
396* A lot of bugfixes (binary, datetime, 64 bit arches, GIL, .executemany())
397
398What's new in psycopg 1.99.13
399-----------------------------
400
401* Added missing .executemany() method.
402
403* Optimized type cast from PostgreSQL to Python (psycopg should be even
404 faster than before.)
405
406What's new in psycopg 1.99.12
407-----------------------------
408
409* .rowcount should be ok and in sync with psycopg 1.
410
411* Implemented the new COPY FROM/COPY TO code when connection to the
412 backend using libpq protocol 3 (this also removes all asprintf calls:
413 build on win32 works again.) A protocol 3-enabled psycopg *can*
414 connect to an old protocol 2 database and will detect it and use the
415 right code.
416
417* getquoted() called for real by the mogrification code.
418
419What's new in psycopg 1.99.11
420-----------------------------
421
422* 'cursor' argument in .cursor() connection method renamed to
423 'cursor_factory'.
424
425* changed 'tuple_factory' cursor attribute name to 'row_factory'.
426
427* the .cursor attribute is gone and connections and cursors are propely
428 gc-managed.
429
430* fixes to the async core.
431
432What's new in psycopg 1.99.10
433-----------------------------
434
435* The adapt() function now fully supports the adaptation protocol
436 described in PEP 246. Note that the adapters registry now is indexed
437 by (type, protocol) and not by type alone. Change your adapters
438 accordingly.
439
440* More configuration options moved from setup.py to setup.cfg.
441
442* Fixed two memory leaks: one in cursor deallocation and one in row
443 fetching (.fetchXXX() methods.)
444
445What's new in psycopg 1.99.9
446----------------------------
447
448* Added simple pooling code (psycopg.pool module); see the reworked
449 examples/threads.py for example code.
450
451* Added DECIMAL typecaster to convert postgresql DECIMAL and NUMERIC
452 types (i.e, all types with an OID of NUMERICOID.) Note that the
453 DECIMAL typecaster does not set scale and precision on the created
454 objects but uses Python defaults.
455
456* ZPsycopgDA back in and working using the new pooling code.
457
458* Isn't that enough? :)
459
460What's new in psycopg 1.99.8
461----------------------------
462
463* added support for UNICODE queries.
464
465* added UNICODE typecaster; to activate it just do:
466
467 psycopg.extensions.register_type(psycopg.extensions.UNICODE)
468
469 Note that the UNICODE typecaster override the STRING one, so it is
470 not activated by default.
471
472* cursors now really support the iterator protocol.
473
474* solved the rounding errors in time conversions.
475
476* now cursors support .fileno() and .isready() methods, to be used in
477 select() calls.
478
479* .copy_from() and .copy_in() methods are back in (still using the old
480 protocol, will be updated to use new one in next releasae.)
481
482* fixed memory corruption bug reported on win32 platform.
483
484What's new in psycopg 1.99.7
485----------------------------
486
487* added support for tuple factories in cursor objects (removed factory
488 argument in favor of a .tuple_factory attribute on the cursor object);
489 see the new module psycopg.extras for a cursor (DictCursor) that
490 return rows as objects that support indexing both by position and
491 column name.
492
493* added support for tzinfo objects in datetime.timestamp objects: the
494 PostgreSQL type "timestamp with time zone" is converted to
495 datetime.timestamp with a FixedOffsetTimezone initialized as necessary.
496
497What's new in psycopg 1.99.6
498----------------------------
499
500* sslmode parameter from 1.1.x
501
502* various datetime conversion improvements.
503
504* now psycopg should compile without mx or without native datetime
505 (not both, obviously.)
506
507* included various win32/MSVC fixes (pthread.h changes, winsock2
508 library, include path in setup.py, etc.)
509
510* ported interval fixes from 1.1.14/1.1.15.
511
512* the last query executed by a cursor is now available in the
513 .query attribute.
514
515* conversion of unicode strings to backend encoding now uses a table
516 (that still need to be filled.)
517
518* cursors now have a .mogrify() method that return the query string
519 instead of executing it.
520
521* connection objects now have a .dsn read-only attribute that holds the
522 connection string.
523
524* moved psycopg C module to _psycopg and made psycopg a python module:
525 this allows for a neat separation of DBAPI-2.0 functionality and psycopg
526 extensions; the psycopg namespace will be also used to provide
527 python-only extensions (like the pooling code, some ZPsycopgDA support
528 functions and the like.)
529
530What's new in psycopg 1.99.3
531----------------------------
532
533* added support for python 2.3 datetime types (both ways) and made datetime
534 the default set of typecasters when available.
535
536* added example: dt.py.
537
538What's new in psycopg 1.99.3
539----------------------------
540
541* initial working support for unicode bound variables: UTF-8 and latin-1
542 backend encodings are natively supported (and the encoding.py example even
543 works!)
544
545* added .set_client_encoding() method on the connection object.
546
547* added examples: encoding.py, binary.py, lastrowid.py.
548
549What's new in psycopg 1.99.2
550----------------------------
551
552* better typecasting:
553 - DateTimeDelta used for postgresql TIME (merge from 1.1)
554 - BYTEA now is converted to a real buffer object, not to a string
555
556* buffer objects are now adapted into Binary objects automatically.
557
558* ported scroll method from 1.1 (DBAPI-2.0 extension for cursors)
559
560* initial support for some DBAPI-2.0 extensions:
561 - .rownumber attribute for cursors
562 - .connection attribute for cursors
563 - .next() and .__iter__() methods to have cursors support the iterator
564 protocol
565 - all exception objects are exported to the connection object
566
567What's new in psycopg 1.99.1
568----------------------------
569
570* implemented microprotocols to adapt arbitrary types to the interface used by
571 psycopg to bind variables in execute;
572
573* moved qstring, pboolean and mxdatetime to the new adapter layout (binary is
574 still missing; python 2.3 datetime needs to be written).
575
576
577What's new in psycopg 1.99.0
578----------------------------
579
580* reorganized the whole source tree;
581
582* async core is in place;
583
584* splitted QuotedString objects from mx stuff;
585
586* dropped autotools and moved to pythonic setup.py (needs work.)
0587
=== added file 'NEWS-2.2'
--- NEWS-2.2 1970-01-01 00:00:00 +0000
+++ NEWS-2.2 2010-07-28 20:35:51 +0000
@@ -0,0 +1,39 @@
1What's new in psycopg 2.2.1
2---------------------------
3
4* Bux fixes:
5 - psycopg now builds again on MS Windows.
6
7
8What's new in psycopg 2.2.0
9---------------------------
10
11This is the first release of the new 2.2 series, supporting not just one but
12two different ways of executing asynchronous queries, thanks to Jan and Daniele
13(with a little help from me and others, but they did 99% of the work so they
14deserve their names here in the news.)
15
16psycopg now supports both classic select() loops and "green" coroutine
17libraries. It is all in the documentation, so just point your browser to
18doc/html/advanced.html.
19
20* Other new features:
21 - truncate() method for lobjects.
22 - COPY functions are now a little bit faster.
23 - All builtin PostgreSQL to Python typecasters are now available from the
24 psycopg2.extensions module.
25 - Notifications from the backend are now available right after the execute()
26 call (before client code needed to call isbusy() to ensure NOTIFY
27 reception.)
28 - Better timezone support.
29 - Lots of documentation updates.
30
31* Bug fixes:
32 - Fixed some gc/refcounting problems.
33 - Fixed reference leak in NOTIFY reception.
34 - Fixed problem with PostgreSQL not casting string literals to the correct
35 types in some situations: psycopg now add an explicit cast to dates, times
36 and bytea representations.
37 - Fixed TimestampFromTicks() and TimeFromTicks() for seconds >= 59.5.
38 - Fixed spurious exception raised when calling C typecasters from Python
39 ones.
040
=== modified file 'PKG-INFO'
--- PKG-INFO 2009-10-12 06:50:00 +0000
+++ PKG-INFO 2010-07-28 20:35:51 +0000
@@ -1,6 +1,6 @@
1Metadata-Version: 1.01Metadata-Version: 1.0
2Name: psycopg22Name: psycopg2
3Version: 2.0.133Version: 2.2.1
4Summary: Python-PostgreSQL Database Adapter4Summary: Python-PostgreSQL Database Adapter
5Home-page: http://initd.org/tracker/psycopg5Home-page: http://initd.org/tracker/psycopg
6Author: Federico Di Gregorio6Author: Federico Di Gregorio
@@ -20,9 +20,9 @@
20 brave programmer.20 brave programmer.
21 21
22Platform: any22Platform: any
23Classifier: Development Status :: 4 - Beta23Classifier: Development Status :: 5 - Production/Stable
24Classifier: Intended Audience :: Developers24Classifier: Intended Audience :: Developers
25Classifier: License :: OSI Approved :: GNU General Public License (GPL)25Classifier: License :: OSI Approved :: GNU Lesser General Public License (LGPL)
26Classifier: License :: OSI Approved :: Zope Public License26Classifier: License :: OSI Approved :: Zope Public License
27Classifier: Programming Language :: Python27Classifier: Programming Language :: Python
28Classifier: Programming Language :: C28Classifier: Programming Language :: C
2929
=== modified file 'README'
--- README 2006-08-09 10:28:30 +0000
+++ README 2010-07-28 20:35:51 +0000
@@ -1,28 +1,32 @@
1psycopg - Python-PostgreSQL Database Adapter1psycopg2 - Python-PostgreSQL Database Adapter
2********************************************2********************************************
33
4psycopg is a PostgreSQL database adapter for the Python programming4psycopg2 is a PostgreSQL database adapter for the Python programming
5language. This is version 2, a complete rewrite of the original code to5language. This is version 2, a complete rewrite of the original code to
6provide new-style classes for connection and cursor objects and other6provide new-style classes for connection and cursor objects and other
7sweet candies. Like the original, psycopg 2 was written with the aim of7sweet candies. Like the original, psycopg2 was written with the aim of
8being very small and fast, and stable as a rock.8being very small and fast, and stable as a rock.
99
10psycopg is different from the other database adapter because it was10psycopg2 is different from the other database adapter because it was
11designed for heavily multi-threaded applications that create and destroy11designed for heavily multi-threaded applications that create and destroy
12lots of cursors and make a conspicuous number of concurrent INSERTs or12lots of cursors and make a conspicuous number of concurrent INSERTs or
13UPDATEs. psycopg 2 also provide full asycronous operations for the really13UPDATEs. psycopg2 also provide full asycronous operations for the really
14brave programmer.14brave programmer.
1515
16There are confirmed reports of psycopg 1.x compiling and running on Linux16There are confirmed reports of psycopg 1.x compiling and running on Linux
17and FreeBSD on i386, Solaris, MacOS X and win32 architectures. psycopg 217and FreeBSD on i386, Solaris, MacOS X and win32 architectures. psycopg2
18does not introduce build-wise incompatible changes so it should be able to18does not introduce build-wise incompatible changes so it should be able to
19compile on all architectures just as its predecessor did.19compile on all architectures just as its predecessor did.
2020
21Now go read the INSTALL file. More information about psycopg extensions to21Now go read the INSTALL file. More information about psycopg2 extensions to
22the DBAPI-2.0 is available in the files located in the doc/ direcory.22the DBAPI-2.0 is available in the files located in the doc/ direcory.
23Example code can be found in the examples/ directory. If you make any changes
24to the code make sure to run the unit tests localed in tests/.
2325
24psycopg is free software ("free as in freedom" but I like beer too.)26psycopg2 is free software ("free as in freedom" but I like beer too.)
25Licensing information is available in the LICENSE file.27It is licensed under the GNU Lesser General Public License, version 3 or
28later plus an exception to allow OpenSSL (libpq) linking; see LICENSE for
29more details.
2630
2731
28Contributors32Contributors
2933
=== modified file 'ZPsycopgDA/DA.py'
--- ZPsycopgDA/DA.py 2009-10-12 06:50:00 +0000
+++ ZPsycopgDA/DA.py 2010-07-28 20:35:51 +0000
@@ -1,24 +1,22 @@
1# ZPsycopgDA/DA.py - ZPsycopgDA Zope product: Database Connection1# ZPsycopgDA/DA.py - ZPsycopgDA Zope product: Database Connection
2#2#
3# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org>3# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org>
4#4#
5# This program is free software; you can redistribute it and/or modify5# psycopg2 is free software: you can redistribute it and/or modify it
6# it under the terms of the GNU General Public License as published by the6# under the terms of the GNU Lesser General Public License as published
7# Free Software Foundation; either version 2, or (at your option) any later7# by the Free Software Foundation, either version 3 of the License, or
8# version.8# (at your option) any later version.
9#9#
10# Or, at your option this program (ZPsycopgDA) can be distributed under the10# psycopg2 is distributed in the hope that it will be useful, but WITHOUT
11# Zope Public License (ZPL) Version 1.0, as published on the Zope web site,11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# http://www.zope.org/Resources/ZPL.12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13#13# License for more details.
14# This program is distributed in the hope that it will be useful, but14
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY15# Import modules needed by _psycopg to allow tools like py2exe to do
16# or FITNESS FOR A PARTICULAR PURPOSE.16# their work without bothering about the module dependencies.
17#17
18# See the LICENSE file for details.18
1919ALLOWED_PSYCOPG_VERSIONS = ('2.2.0','2.2.1')
20
21ALLOWED_PSYCOPG_VERSIONS = ('2.0.7','2.0.8','2.0.9','2.0.10', '2.0.11', '2.0.12', '2.0.13')
2220
23import sys21import sys
24import time22import time
2523
=== modified file 'ZPsycopgDA/__init__.py'
--- ZPsycopgDA/__init__.py 2006-08-09 10:28:30 +0000
+++ ZPsycopgDA/__init__.py 2010-07-28 20:35:51 +0000
@@ -1,21 +1,19 @@
1# ZPsycopgDA/__init__.py - ZPsycopgDA Zope product1# ZPsycopgDA/__init__.py - ZPsycopgDA Zope product
2#2#
3# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org>3# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org>
4#4#
5# This program is free software; you can redistribute it and/or modify5# psycopg2 is free software: you can redistribute it and/or modify it
6# it under the terms of the GNU General Public License as published by the6# under the terms of the GNU Lesser General Public License as published
7# Free Software Foundation; either version 2, or (at your option) any later7# by the Free Software Foundation, either version 3 of the License, or
8# version.8# (at your option) any later version.
9#9#
10# Or, at your option this program (ZPsycopgDA) can be distributed under the10# psycopg2 is distributed in the hope that it will be useful, but WITHOUT
11# Zope Public License (ZPL) Version 1.0, as published on the Zope web site,11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# http://www.zope.org/Resources/ZPL.12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13#13# License for more details.
14# This program is distributed in the hope that it will be useful, but14
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY15# Import modules needed by _psycopg to allow tools like py2exe to do
16# or FITNESS FOR A PARTICULAR PURPOSE.16# their work without bothering about the module dependencies.
17#
18# See the LICENSE file for details.
1917
20__doc__ = "ZPsycopg Database Adapter Registration." 18__doc__ = "ZPsycopg Database Adapter Registration."
21__version__ = '2.0'19__version__ = '2.0'
2220
=== modified file 'ZPsycopgDA/db.py'
--- ZPsycopgDA/db.py 2009-08-27 18:05:48 +0000
+++ ZPsycopgDA/db.py 2010-07-28 20:35:51 +0000
@@ -1,21 +1,19 @@
1# ZPsycopgDA/db.py - query execution1# ZPsycopgDA/db.py - query execution
2#2#
3# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org>3# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org>
4#4#
5# This program is free software; you can redistribute it and/or modify5# psycopg2 is free software: you can redistribute it and/or modify it
6# it under the terms of the GNU General Public License as published by the6# under the terms of the GNU Lesser General Public License as published
7# Free Software Foundation; either version 2, or (at your option) any later7# by the Free Software Foundation, either version 3 of the License, or
8# version.8# (at your option) any later version.
9#9#
10# Or, at your option this program (ZPsycopgDA) can be distributed under the10# psycopg2 is distributed in the hope that it will be useful, but WITHOUT
11# Zope Public License (ZPL) Version 1.0, as published on the Zope web site,11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# http://www.zope.org/Resources/ZPL.12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13#13# License for more details.
14# This program is distributed in the hope that it will be useful, but14
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY15# Import modules needed by _psycopg to allow tools like py2exe to do
16# or FITNESS FOR A PARTICULAR PURPOSE.16# their work without bothering about the module dependencies.
17#
18# See the LICENSE file for details.
1917
20from Shared.DC.ZRDB.TM import TM18from Shared.DC.ZRDB.TM import TM
21from Shared.DC.ZRDB import dbi_db19from Shared.DC.ZRDB import dbi_db
@@ -171,15 +169,15 @@
171 c.execute(qs)169 c.execute(qs)
172 except TransactionRollbackError:170 except TransactionRollbackError:
173 # Ha, here we have to look like we are the ZODB raising conflict errrors, raising ZPublisher.Publish.Retry just doesn't work171 # Ha, here we have to look like we are the ZODB raising conflict errrors, raising ZPublisher.Publish.Retry just doesn't work
174 logging.debug("Serialization Error, retrying transaction", exc_info=True)172 #logging.debug("Serialization Error, retrying transaction", exc_info=True)
175 raise ConflictError("TransactionRollbackError from psycopg2")173 raise ConflictError("TransactionRollbackError from psycopg2")
176 except psycopg2.OperationalError:174 except psycopg2.OperationalError:
177 logging.exception("Operational error on connection, closing it.")175 #logging.exception("Operational error on connection, closing it.")
178 try:176 try:
179 # Only close our connection177 # Only close our connection
180 self.putconn(True)178 self.putconn(True)
181 except:179 except:
182 logging.debug("Something went wrong when we tried to close the pool", exc_info=True)180 #logging.debug("Something went wrong when we tried to close the pool", exc_info=True)
183 pass181 pass
184 if c.description is not None:182 if c.description is not None:
185 nselects += 1183 nselects += 1
186184
=== modified file 'ZPsycopgDA/pool.py'
--- ZPsycopgDA/pool.py 2006-08-09 10:28:30 +0000
+++ ZPsycopgDA/pool.py 2010-07-28 20:35:51 +0000
@@ -1,24 +1,22 @@
1# ZPsycopgDA/pool.py - ZPsycopgDA Zope product: connection pooling1# ZPsycopgDA/pool.py - ZPsycopgDA Zope product: connection pooling
2#2#
3# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org>3# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org>
4#4#
5# This program is free software; you can redistribute it and/or modify5# psycopg2 is free software: you can redistribute it and/or modify it
6# it under the terms of the GNU General Public License as published by the6# under the terms of the GNU Lesser General Public License as published
7# Free Software Foundation; either version 2, or (at your option) any later7# by the Free Software Foundation, either version 3 of the License, or
8# version.8# (at your option) any later version.
9#9#
10# Or, at your option this program (ZPsycopgDA) can be distributed under the10# psycopg2 is distributed in the hope that it will be useful, but WITHOUT
11# Zope Public License (ZPL) Version 1.0, as published on the Zope web site,11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# http://www.zope.org/Resources/ZPL.12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13#13# License for more details.
14# This program is distributed in the hope that it will be useful, but14
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY15# Import modules needed by _psycopg to allow tools like py2exe to do
16# or FITNESS FOR A PARTICULAR PURPOSE.16# their work without bothering about the module dependencies.
17#17
18# See the LICENSE file for details.18# All the connections are held in a pool of pools, directly accessible by the
1919# ZPsycopgDA code in db.py.
20# all the connections are held in a pool of pools, directly accessible by the
21# ZPsycopgDA code in db.py
2220
23import threading21import threading
24import psycopg2.pool22import psycopg2.pool
2523
=== modified file 'debian/changelog'
--- debian/changelog 2010-04-16 10:05:03 +0000
+++ debian/changelog 2010-07-28 20:35:51 +0000
@@ -1,3 +1,26 @@
1psycopg2 (2.2.1-1ubuntu1) maverick; urgency=low
2
3 * Merge from Debian (LP: #611040). Remaining changes:
4 debian/control, debian/rules: Install a seperate testsuite package.
5
6 -- Mikhail Turov <groldster@gmail.com> Wed, 28 Jul 2010 21:20:45 +0100
7
8psycopg2 (2.2.1-1) unstable; urgency=low
9
10 * New upstream release. (Closes: #582823)
11 * debian/control:
12 - bumped Standards-Version to 3.9.0, no changes required.
13 - removed the zope-psycopg2da binary package. (Closes: #583293)
14
15 -- Fabio Tranchitella <kobold@debian.org> Fri, 02 Jul 2010 15:04:19 +0200
16
17psycopg2 (2.0.14-1) unstable; urgency=low
18
19 * New upstream release.
20 * debian/control: bumped Standards-Version to 3.8.5, no changes required.
21
22 -- Fabio Tranchitella <kobold@debian.org> Sat, 10 Apr 2010 10:32:45 +0200
23
1psycopg2 (2.0.13-2ubuntu2) lucid; urgency=low24psycopg2 (2.0.13-2ubuntu2) lucid; urgency=low
225
3 * Drop the zope2 package as we have no zope2 in lucid.26 * Drop the zope2 package as we have no zope2 in lucid.
@@ -388,13 +411,6 @@
388411
389 -- Federico Di Gregorio <fog@debian.org> Fri, 1 Aug 2003 11:50:57 +0200412 -- Federico Di Gregorio <fog@debian.org> Fri, 1 Aug 2003 11:50:57 +0200
390413
391psycopg (1.1.5.1-1.1) unstable; urgency=low
392
393 * NMU
394 * Update for python2.3 as the default python version (closes: #205746).
395
396 -- Matthias Klose <doko@debian.org> Fri, 22 Aug 2003 00:02:25 +0200
397
398psycopg (1.1.7-1) unstable; urgency=low414psycopg (1.1.7-1) unstable; urgency=low
399415
400 * New upstream release.416 * New upstream release.
@@ -408,6 +424,13 @@
408 424
409 -- Federico Di Gregorio <fog@initd.org> Sun, 13 Jul 2003 23:36:04 +0200425 -- Federico Di Gregorio <fog@initd.org> Sun, 13 Jul 2003 23:36:04 +0200
410426
427psycopg (1.1.5.1-1.1) unstable; urgency=low
428
429 * NMU
430 * Update for python2.3 as the default python version (closes: #205746).
431
432 -- Matthias Klose <doko@debian.org> Fri, 22 Aug 2003 00:02:25 +0200
433
411psycopg (1.1.5.1-1) unstable; urgency=low434psycopg (1.1.5.1-1) unstable; urgency=low
412435
413 * New upstream release.436 * New upstream release.
414437
=== modified file 'debian/control'
--- debian/control 2010-04-16 10:05:03 +0000
+++ debian/control 2010-07-28 20:35:51 +0000
@@ -4,7 +4,7 @@
4Build-Depends: debhelper (>= 5.0.37.2), python-all-dev, python-all-dbg, python-central (>= 0.5.0), python (>= 2.3.5-7), python-egenix-mx-base-dev, autoconf, libpq-dev4Build-Depends: debhelper (>= 5.0.37.2), python-all-dev, python-all-dbg, python-central (>= 0.5.0), python (>= 2.3.5-7), python-egenix-mx-base-dev, autoconf, libpq-dev
5Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>5Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
6XSBC-Original-Maintainer: Fabio Tranchitella <kobold@debian.org>6XSBC-Original-Maintainer: Fabio Tranchitella <kobold@debian.org>
7Standards-Version: 3.8.37Standards-Version: 3.9.0
8XS-Python-Version: all8XS-Python-Version: all
9Vcs-Svn: svn://svn.debian.org/python-modules/packages/psycopg2/trunk/9Vcs-Svn: svn://svn.debian.org/python-modules/packages/psycopg2/trunk/
10Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/psycopg2/trunk/10Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/psycopg2/trunk/
@@ -13,7 +13,7 @@
13Package: python-psycopg213Package: python-psycopg2
14Architecture: any14Architecture: any
15Section: python15Section: python
16Depends: ${python:Depends}, ${shlibs:Depends}, python-egenix-mxdatetime16Depends: python-egenix-mxdatetime, ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}
17Provides: ${python:Provides}17Provides: ${python:Provides}
18XB-Python-Version: ${python:Versions}18XB-Python-Version: ${python:Versions}
19Description: Python module for PostgreSQL19Description: Python module for PostgreSQL
@@ -37,7 +37,7 @@
37Priority: extra37Priority: extra
38Architecture: any38Architecture: any
39Section: debug39Section: debug
40Depends: python-psycopg2 (= ${binary:Version}), python-dbg, ${shlibs:Depends}40Depends: python-psycopg2 (= ${binary:Version}), python-dbg, ${shlibs:Depends}, ${misc:Depends}
41XB-Python-Version: ${python:Versions}41XB-Python-Version: ${python:Versions}
42Description: Python module for PostgreSQL (debug extension)42Description: Python module for PostgreSQL (debug extension)
43 psycopg is a PostgreSQL database adapter for the Python programming language43 psycopg is a PostgreSQL database adapter for the Python programming language
@@ -48,15 +48,6 @@
48 .48 .
49 This package contains the extensions built for the Python debug interpreter.49 This package contains the extensions built for the Python debug interpreter.
5050
51#Package: zope-psycopgda2
52#Architecture: all
53#Section: zope
54#Depends: ${zope:Depends}, python-psycopg2 (>= ${source:Version})
55#XB-Python-Version: ${python:Versions}
56#Description: Zope database adapter based on python-psycopg2
57# The package contains the PostgreSQL database adapter for Zope 2.7, 2.8 and
58# 2.9 based on the psycopg2 Python module.
59
60Package: python-psycopg2-testsuite51Package: python-psycopg2-testsuite
61Architecture: any52Architecture: any
62Section: python53Section: python
6354
=== modified file 'debian/rules'
--- debian/rules 2010-04-16 10:05:03 +0000
+++ debian/rules 2010-07-28 20:35:51 +0000
@@ -59,8 +59,6 @@
59 find debian/python-*-dbg -depth -empty -exec rmdir {} \;59 find debian/python-*-dbg -depth -empty -exec rmdir {} \;
6060
61install-indep: build61install-indep: build
62 # Zope package
63 #dh_installzope -p zope-psycopgda2 ZPsycopgDA
6462
65# Build architecture-independent files here.63# Build architecture-independent files here.
66binary-indep: build install-indep64binary-indep: build install-indep
6765
=== added directory 'debian/source'
=== added file 'debian/source/format'
--- debian/source/format 1970-01-01 00:00:00 +0000
+++ debian/source/format 2010-07-28 20:35:51 +0000
@@ -0,0 +1,1 @@
11.0
02
=== added file 'doc/COPYING'
--- doc/COPYING 1970-01-01 00:00:00 +0000
+++ doc/COPYING 2010-07-28 20:35:51 +0000
@@ -0,0 +1,676 @@
1
2 GNU GENERAL PUBLIC LICENSE
3 Version 3, 29 June 2007
4
5 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The GNU General Public License is a free, copyleft license for
12software and other kinds of works.
13
14 The licenses for most software and other practical works are designed
15to take away your freedom to share and change the works. By contrast,
16the GNU General Public License is intended to guarantee your freedom to
17share and change all versions of a program--to make sure it remains free
18software for all its users. We, the Free Software Foundation, use the
19GNU General Public License for most of our software; it applies also to
20any other work released this way by its authors. You can apply it to
21your programs, too.
22
23 When we speak of free software, we are referring to freedom, not
24price. Our General Public Licenses are designed to make sure that you
25have the freedom to distribute copies of free software (and charge for
26them if you wish), that you receive source code or can get it if you
27want it, that you can change the software or use pieces of it in new
28free programs, and that you know you can do these things.
29
30 To protect your rights, we need to prevent others from denying you
31these rights or asking you to surrender the rights. Therefore, you have
32certain responsibilities if you distribute copies of the software, or if
33you modify it: responsibilities to respect the freedom of others.
34
35 For example, if you distribute copies of such a program, whether
36gratis or for a fee, you must pass on to the recipients the same
37freedoms that you received. You must make sure that they, too, receive
38or can get the source code. And you must show them these terms so they
39know their rights.
40
41 Developers that use the GNU GPL protect your rights with two steps:
42(1) assert copyright on the software, and (2) offer you this License
43giving you legal permission to copy, distribute and/or modify it.
44
45 For the developers' and authors' protection, the GPL clearly explains
46that there is no warranty for this free software. For both users' and
47authors' sake, the GPL requires that modified versions be marked as
48changed, so that their problems will not be attributed erroneously to
49authors of previous versions.
50
51 Some devices are designed to deny users access to install or run
52modified versions of the software inside them, although the manufacturer
53can do so. This is fundamentally incompatible with the aim of
54protecting users' freedom to change the software. The systematic
55pattern of such abuse occurs in the area of products for individuals to
56use, which is precisely where it is most unacceptable. Therefore, we
57have designed this version of the GPL to prohibit the practice for those
58products. If such problems arise substantially in other domains, we
59stand ready to extend this provision to those domains in future versions
60of the GPL, as needed to protect the freedom of users.
61
62 Finally, every program is threatened constantly by software patents.
63States should not allow patents to restrict development and use of
64software on general-purpose computers, but in those that do, we wish to
65avoid the special danger that patents applied to a free program could
66make it effectively proprietary. To prevent this, the GPL assures that
67patents cannot be used to render the program non-free.
68
69 The precise terms and conditions for copying, distribution and
70modification follow.
71
72 TERMS AND CONDITIONS
73
74 0. Definitions.
75
76 "This License" refers to version 3 of the GNU General Public License.
77
78 "Copyright" also means copyright-like laws that apply to other kinds of
79works, such as semiconductor masks.
80
81 "The Program" refers to any copyrightable work licensed under this
82License. Each licensee is addressed as "you". "Licensees" and
83"recipients" may be individuals or organizations.
84
85 To "modify" a work means to copy from or adapt all or part of the work
86in a fashion requiring copyright permission, other than the making of an
87exact copy. The resulting work is called a "modified version" of the
88earlier work or a work "based on" the earlier work.
89
90 A "covered work" means either the unmodified Program or a work based
91on the Program.
92
93 To "propagate" a work means to do anything with it that, without
94permission, would make you directly or secondarily liable for
95infringement under applicable copyright law, except executing it on a
96computer or modifying a private copy. Propagation includes copying,
97distribution (with or without modification), making available to the
98public, and in some countries other activities as well.
99
100 To "convey" a work means any kind of propagation that enables other
101parties to make or receive copies. Mere interaction with a user through
102a computer network, with no transfer of a copy, is not conveying.
103
104 An interactive user interface displays "Appropriate Legal Notices"
105to the extent that it includes a convenient and prominently visible
106feature that (1) displays an appropriate copyright notice, and (2)
107tells the user that there is no warranty for the work (except to the
108extent that warranties are provided), that licensees may convey the
109work under this License, and how to view a copy of this License. If
110the interface presents a list of user commands or options, such as a
111menu, a prominent item in the list meets this criterion.
112
113 1. Source Code.
114
115 The "source code" for a work means the preferred form of the work
116for making modifications to it. "Object code" means any non-source
117form of a work.
118
119 A "Standard Interface" means an interface that either is an official
120standard defined by a recognized standards body, or, in the case of
121interfaces specified for a particular programming language, one that
122is widely used among developers working in that language.
123
124 The "System Libraries" of an executable work include anything, other
125than the work as a whole, that (a) is included in the normal form of
126packaging a Major Component, but which is not part of that Major
127Component, and (b) serves only to enable use of the work with that
128Major Component, or to implement a Standard Interface for which an
129implementation is available to the public in source code form. A
130"Major Component", in this context, means a major essential component
131(kernel, window system, and so on) of the specific operating system
132(if any) on which the executable work runs, or a compiler used to
133produce the work, or an object code interpreter used to run it.
134
135 The "Corresponding Source" for a work in object code form means all
136the source code needed to generate, install, and (for an executable
137work) run the object code and to modify the work, including scripts to
138control those activities. However, it does not include the work's
139System Libraries, or general-purpose tools or generally available free
140programs which are used unmodified in performing those activities but
141which are not part of the work. For example, Corresponding Source
142includes interface definition files associated with source files for
143the work, and the source code for shared libraries and dynamically
144linked subprograms that the work is specifically designed to require,
145such as by intimate data communication or control flow between those
146subprograms and other parts of the work.
147
148 The Corresponding Source need not include anything that users
149can regenerate automatically from other parts of the Corresponding
150Source.
151
152 The Corresponding Source for a work in source code form is that
153same work.
154
155 2. Basic Permissions.
156
157 All rights granted under this License are granted for the term of
158copyright on the Program, and are irrevocable provided the stated
159conditions are met. This License explicitly affirms your unlimited
160permission to run the unmodified Program. The output from running a
161covered work is covered by this License only if the output, given its
162content, constitutes a covered work. This License acknowledges your
163rights of fair use or other equivalent, as provided by copyright law.
164
165 You may make, run and propagate covered works that you do not
166convey, without conditions so long as your license otherwise remains
167in force. You may convey covered works to others for the sole purpose
168of having them make modifications exclusively for you, or provide you
169with facilities for running those works, provided that you comply with
170the terms of this License in conveying all material for which you do
171not control copyright. Those thus making or running the covered works
172for you must do so exclusively on your behalf, under your direction
173and control, on terms that prohibit them from making any copies of
174your copyrighted material outside their relationship with you.
175
176 Conveying under any other circumstances is permitted solely under
177the conditions stated below. Sublicensing is not allowed; section 10
178makes it unnecessary.
179
180 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
181
182 No covered work shall be deemed part of an effective technological
183measure under any applicable law fulfilling obligations under article
18411 of the WIPO copyright treaty adopted on 20 December 1996, or
185similar laws prohibiting or restricting circumvention of such
186measures.
187
188 When you convey a covered work, you waive any legal power to forbid
189circumvention of technological measures to the extent such circumvention
190is effected by exercising rights under this License with respect to
191the covered work, and you disclaim any intention to limit operation or
192modification of the work as a means of enforcing, against the work's
193users, your or third parties' legal rights to forbid circumvention of
194technological measures.
195
196 4. Conveying Verbatim Copies.
197
198 You may convey verbatim copies of the Program's source code as you
199receive it, in any medium, provided that you conspicuously and
200appropriately publish on each copy an appropriate copyright notice;
201keep intact all notices stating that this License and any
202non-permissive terms added in accord with section 7 apply to the code;
203keep intact all notices of the absence of any warranty; and give all
204recipients a copy of this License along with the Program.
205
206 You may charge any price or no price for each copy that you convey,
207and you may offer support or warranty protection for a fee.
208
209 5. Conveying Modified Source Versions.
210
211 You may convey a work based on the Program, or the modifications to
212produce it from the Program, in the form of source code under the
213terms of section 4, provided that you also meet all of these conditions:
214
215 a) The work must carry prominent notices stating that you modified
216 it, and giving a relevant date.
217
218 b) The work must carry prominent notices stating that it is
219 released under this License and any conditions added under section
220 7. This requirement modifies the requirement in section 4 to
221 "keep intact all notices".
222
223 c) You must license the entire work, as a whole, under this
224 License to anyone who comes into possession of a copy. This
225 License will therefore apply, along with any applicable section 7
226 additional terms, to the whole of the work, and all its parts,
227 regardless of how they are packaged. This License gives no
228 permission to license the work in any other way, but it does not
229 invalidate such permission if you have separately received it.
230
231 d) If the work has interactive user interfaces, each must display
232 Appropriate Legal Notices; however, if the Program has interactive
233 interfaces that do not display Appropriate Legal Notices, your
234 work need not make them do so.
235
236 A compilation of a covered work with other separate and independent
237works, which are not by their nature extensions of the covered work,
238and which are not combined with it such as to form a larger program,
239in or on a volume of a storage or distribution medium, is called an
240"aggregate" if the compilation and its resulting copyright are not
241used to limit the access or legal rights of the compilation's users
242beyond what the individual works permit. Inclusion of a covered work
243in an aggregate does not cause this License to apply to the other
244parts of the aggregate.
245
246 6. Conveying Non-Source Forms.
247
248 You may convey a covered work in object code form under the terms
249of sections 4 and 5, provided that you also convey the
250machine-readable Corresponding Source under the terms of this License,
251in one of these ways:
252
253 a) Convey the object code in, or embodied in, a physical product
254 (including a physical distribution medium), accompanied by the
255 Corresponding Source fixed on a durable physical medium
256 customarily used for software interchange.
257
258 b) Convey the object code in, or embodied in, a physical product
259 (including a physical distribution medium), accompanied by a
260 written offer, valid for at least three years and valid for as
261 long as you offer spare parts or customer support for that product
262 model, to give anyone who possesses the object code either (1) a
263 copy of the Corresponding Source for all the software in the
264 product that is covered by this License, on a durable physical
265 medium customarily used for software interchange, for a price no
266 more than your reasonable cost of physically performing this
267 conveying of source, or (2) access to copy the
268 Corresponding Source from a network server at no charge.
269
270 c) Convey individual copies of the object code with a copy of the
271 written offer to provide the Corresponding Source. This
272 alternative is allowed only occasionally and noncommercially, and
273 only if you received the object code with such an offer, in accord
274 with subsection 6b.
275
276 d) Convey the object code by offering access from a designated
277 place (gratis or for a charge), and offer equivalent access to the
278 Corresponding Source in the same way through the same place at no
279 further charge. You need not require recipients to copy the
280 Corresponding Source along with the object code. If the place to
281 copy the object code is a network server, the Corresponding Source
282 may be on a different server (operated by you or a third party)
283 that supports equivalent copying facilities, provided you maintain
284 clear directions next to the object code saying where to find the
285 Corresponding Source. Regardless of what server hosts the
286 Corresponding Source, you remain obligated to ensure that it is
287 available for as long as needed to satisfy these requirements.
288
289 e) Convey the object code using peer-to-peer transmission, provided
290 you inform other peers where the object code and Corresponding
291 Source of the work are being offered to the general public at no
292 charge under subsection 6d.
293
294 A separable portion of the object code, whose source code is excluded
295from the Corresponding Source as a System Library, need not be
296included in conveying the object code work.
297
298 A "User Product" is either (1) a "consumer product", which means any
299tangible personal property which is normally used for personal, family,
300or household purposes, or (2) anything designed or sold for incorporation
301into a dwelling. In determining whether a product is a consumer product,
302doubtful cases shall be resolved in favor of coverage. For a particular
303product received by a particular user, "normally used" refers to a
304typical or common use of that class of product, regardless of the status
305of the particular user or of the way in which the particular user
306actually uses, or expects or is expected to use, the product. A product
307is a consumer product regardless of whether the product has substantial
308commercial, industrial or non-consumer uses, unless such uses represent
309the only significant mode of use of the product.
310
311 "Installation Information" for a User Product means any methods,
312procedures, authorization keys, or other information required to install
313and execute modified versions of a covered work in that User Product from
314a modified version of its Corresponding Source. The information must
315suffice to ensure that the continued functioning of the modified object
316code is in no case prevented or interfered with solely because
317modification has been made.
318
319 If you convey an object code work under this section in, or with, or
320specifically for use in, a User Product, and the conveying occurs as
321part of a transaction in which the right of possession and use of the
322User Product is transferred to the recipient in perpetuity or for a
323fixed term (regardless of how the transaction is characterized), the
324Corresponding Source conveyed under this section must be accompanied
325by the Installation Information. But this requirement does not apply
326if neither you nor any third party retains the ability to install
327modified object code on the User Product (for example, the work has
328been installed in ROM).
329
330 The requirement to provide Installation Information does not include a
331requirement to continue to provide support service, warranty, or updates
332for a work that has been modified or installed by the recipient, or for
333the User Product in which it has been modified or installed. Access to a
334network may be denied when the modification itself materially and
335adversely affects the operation of the network or violates the rules and
336protocols for communication across the network.
337
338 Corresponding Source conveyed, and Installation Information provided,
339in accord with this section must be in a format that is publicly
340documented (and with an implementation available to the public in
341source code form), and must require no special password or key for
342unpacking, reading or copying.
343
344 7. Additional Terms.
345
346 "Additional permissions" are terms that supplement the terms of this
347License by making exceptions from one or more of its conditions.
348Additional permissions that are applicable to the entire Program shall
349be treated as though they were included in this License, to the extent
350that they are valid under applicable law. If additional permissions
351apply only to part of the Program, that part may be used separately
352under those permissions, but the entire Program remains governed by
353this License without regard to the additional permissions.
354
355 When you convey a copy of a covered work, you may at your option
356remove any additional permissions from that copy, or from any part of
357it. (Additional permissions may be written to require their own
358removal in certain cases when you modify the work.) You may place
359additional permissions on material, added by you to a covered work,
360for which you have or can give appropriate copyright permission.
361
362 Notwithstanding any other provision of this License, for material you
363add to a covered work, you may (if authorized by the copyright holders of
364that material) supplement the terms of this License with terms:
365
366 a) Disclaiming warranty or limiting liability differently from the
367 terms of sections 15 and 16 of this License; or
368
369 b) Requiring preservation of specified reasonable legal notices or
370 author attributions in that material or in the Appropriate Legal
371 Notices displayed by works containing it; or
372
373 c) Prohibiting misrepresentation of the origin of that material, or
374 requiring that modified versions of such material be marked in
375 reasonable ways as different from the original version; or
376
377 d) Limiting the use for publicity purposes of names of licensors or
378 authors of the material; or
379
380 e) Declining to grant rights under trademark law for use of some
381 trade names, trademarks, or service marks; or
382
383 f) Requiring indemnification of licensors and authors of that
384 material by anyone who conveys the material (or modified versions of
385 it) with contractual assumptions of liability to the recipient, for
386 any liability that these contractual assumptions directly impose on
387 those licensors and authors.
388
389 All other non-permissive additional terms are considered "further
390restrictions" within the meaning of section 10. If the Program as you
391received it, or any part of it, contains a notice stating that it is
392governed by this License along with a term that is a further
393restriction, you may remove that term. If a license document contains
394a further restriction but permits relicensing or conveying under this
395License, you may add to a covered work material governed by the terms
396of that license document, provided that the further restriction does
397not survive such relicensing or conveying.
398
399 If you add terms to a covered work in accord with this section, you
400must place, in the relevant source files, a statement of the
401additional terms that apply to those files, or a notice indicating
402where to find the applicable terms.
403
404 Additional terms, permissive or non-permissive, may be stated in the
405form of a separately written license, or stated as exceptions;
406the above requirements apply either way.
407
408 8. Termination.
409
410 You may not propagate or modify a covered work except as expressly
411provided under this License. Any attempt otherwise to propagate or
412modify it is void, and will automatically terminate your rights under
413this License (including any patent licenses granted under the third
414paragraph of section 11).
415
416 However, if you cease all violation of this License, then your
417license from a particular copyright holder is reinstated (a)
418provisionally, unless and until the copyright holder explicitly and
419finally terminates your license, and (b) permanently, if the copyright
420holder fails to notify you of the violation by some reasonable means
421prior to 60 days after the cessation.
422
423 Moreover, your license from a particular copyright holder is
424reinstated permanently if the copyright holder notifies you of the
425violation by some reasonable means, this is the first time you have
426received notice of violation of this License (for any work) from that
427copyright holder, and you cure the violation prior to 30 days after
428your receipt of the notice.
429
430 Termination of your rights under this section does not terminate the
431licenses of parties who have received copies or rights from you under
432this License. If your rights have been terminated and not permanently
433reinstated, you do not qualify to receive new licenses for the same
434material under section 10.
435
436 9. Acceptance Not Required for Having Copies.
437
438 You are not required to accept this License in order to receive or
439run a copy of the Program. Ancillary propagation of a covered work
440occurring solely as a consequence of using peer-to-peer transmission
441to receive a copy likewise does not require acceptance. However,
442nothing other than this License grants you permission to propagate or
443modify any covered work. These actions infringe copyright if you do
444not accept this License. Therefore, by modifying or propagating a
445covered work, you indicate your acceptance of this License to do so.
446
447 10. Automatic Licensing of Downstream Recipients.
448
449 Each time you convey a covered work, the recipient automatically
450receives a license from the original licensors, to run, modify and
451propagate that work, subject to this License. You are not responsible
452for enforcing compliance by third parties with this License.
453
454 An "entity transaction" is a transaction transferring control of an
455organization, or substantially all assets of one, or subdividing an
456organization, or merging organizations. If propagation of a covered
457work results from an entity transaction, each party to that
458transaction who receives a copy of the work also receives whatever
459licenses to the work the party's predecessor in interest had or could
460give under the previous paragraph, plus a right to possession of the
461Corresponding Source of the work from the predecessor in interest, if
462the predecessor has it or can get it with reasonable efforts.
463
464 You may not impose any further restrictions on the exercise of the
465rights granted or affirmed under this License. For example, you may
466not impose a license fee, royalty, or other charge for exercise of
467rights granted under this License, and you may not initiate litigation
468(including a cross-claim or counterclaim in a lawsuit) alleging that
469any patent claim is infringed by making, using, selling, offering for
470sale, or importing the Program or any portion of it.
471
472 11. Patents.
473
474 A "contributor" is a copyright holder who authorizes use under this
475License of the Program or a work on which the Program is based. The
476work thus licensed is called the contributor's "contributor version".
477
478 A contributor's "essential patent claims" are all patent claims
479owned or controlled by the contributor, whether already acquired or
480hereafter acquired, that would be infringed by some manner, permitted
481by this License, of making, using, or selling its contributor version,
482but do not include claims that would be infringed only as a
483consequence of further modification of the contributor version. For
484purposes of this definition, "control" includes the right to grant
485patent sublicenses in a manner consistent with the requirements of
486this License.
487
488 Each contributor grants you a non-exclusive, worldwide, royalty-free
489patent license under the contributor's essential patent claims, to
490make, use, sell, offer for sale, import and otherwise run, modify and
491propagate the contents of its contributor version.
492
493 In the following three paragraphs, a "patent license" is any express
494agreement or commitment, however denominated, not to enforce a patent
495(such as an express permission to practice a patent or covenant not to
496sue for patent infringement). To "grant" such a patent license to a
497party means to make such an agreement or commitment not to enforce a
498patent against the party.
499
500 If you convey a covered work, knowingly relying on a patent license,
501and the Corresponding Source of the work is not available for anyone
502to copy, free of charge and under the terms of this License, through a
503publicly available network server or other readily accessible means,
504then you must either (1) cause the Corresponding Source to be so
505available, or (2) arrange to deprive yourself of the benefit of the
506patent license for this particular work, or (3) arrange, in a manner
507consistent with the requirements of this License, to extend the patent
508license to downstream recipients. "Knowingly relying" means you have
509actual knowledge that, but for the patent license, your conveying the
510covered work in a country, or your recipient's use of the covered work
511in a country, would infringe one or more identifiable patents in that
512country that you have reason to believe are valid.
513
514 If, pursuant to or in connection with a single transaction or
515arrangement, you convey, or propagate by procuring conveyance of, a
516covered work, and grant a patent license to some of the parties
517receiving the covered work authorizing them to use, propagate, modify
518or convey a specific copy of the covered work, then the patent license
519you grant is automatically extended to all recipients of the covered
520work and works based on it.
521
522 A patent license is "discriminatory" if it does not include within
523the scope of its coverage, prohibits the exercise of, or is
524conditioned on the non-exercise of one or more of the rights that are
525specifically granted under this License. You may not convey a covered
526work if you are a party to an arrangement with a third party that is
527in the business of distributing software, under which you make payment
528to the third party based on the extent of your activity of conveying
529the work, and under which the third party grants, to any of the
530parties who would receive the covered work from you, a discriminatory
531patent license (a) in connection with copies of the covered work
532conveyed by you (or copies made from those copies), or (b) primarily
533for and in connection with specific products or compilations that
534contain the covered work, unless you entered into that arrangement,
535or that patent license was granted, prior to 28 March 2007.
536
537 Nothing in this License shall be construed as excluding or limiting
538any implied license or other defenses to infringement that may
539otherwise be available to you under applicable patent law.
540
541 12. No Surrender of Others' Freedom.
542
543 If conditions are imposed on you (whether by court order, agreement or
544otherwise) that contradict the conditions of this License, they do not
545excuse you from the conditions of this License. If you cannot convey a
546covered work so as to satisfy simultaneously your obligations under this
547License and any other pertinent obligations, then as a consequence you may
548not convey it at all. For example, if you agree to terms that obligate you
549to collect a royalty for further conveying from those to whom you convey
550the Program, the only way you could satisfy both those terms and this
551License would be to refrain entirely from conveying the Program.
552
553 13. Use with the GNU Affero General Public License.
554
555 Notwithstanding any other provision of this License, you have
556permission to link or combine any covered work with a work licensed
557under version 3 of the GNU Affero General Public License into a single
558combined work, and to convey the resulting work. The terms of this
559License will continue to apply to the part which is the covered work,
560but the special requirements of the GNU Affero General Public License,
561section 13, concerning interaction through a network will apply to the
562combination as such.
563
564 14. Revised Versions of this License.
565
566 The Free Software Foundation may publish revised and/or new versions of
567the GNU General Public License from time to time. Such new versions will
568be similar in spirit to the present version, but may differ in detail to
569address new problems or concerns.
570
571 Each version is given a distinguishing version number. If the
572Program specifies that a certain numbered version of the GNU General
573Public License "or any later version" applies to it, you have the
574option of following the terms and conditions either of that numbered
575version or of any later version published by the Free Software
576Foundation. If the Program does not specify a version number of the
577GNU General Public License, you may choose any version ever published
578by the Free Software Foundation.
579
580 If the Program specifies that a proxy can decide which future
581versions of the GNU General Public License can be used, that proxy's
582public statement of acceptance of a version permanently authorizes you
583to choose that version for the Program.
584
585 Later license versions may give you additional or different
586permissions. However, no additional obligations are imposed on any
587author or copyright holder as a result of your choosing to follow a
588later version.
589
590 15. Disclaimer of Warranty.
591
592 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
593APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
594HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
595OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
596THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
597PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
598IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
599ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
600
601 16. Limitation of Liability.
602
603 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
604WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
605THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
606GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
607USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
608DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
609PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
610EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
611SUCH DAMAGES.
612
613 17. Interpretation of Sections 15 and 16.
614
615 If the disclaimer of warranty and limitation of liability provided
616above cannot be given local legal effect according to their terms,
617reviewing courts shall apply local law that most closely approximates
618an absolute waiver of all civil liability in connection with the
619Program, unless a warranty or assumption of liability accompanies a
620copy of the Program in return for a fee.
621
622 END OF TERMS AND CONDITIONS
623
624 How to Apply These Terms to Your New Programs
625
626 If you develop a new program, and you want it to be of the greatest
627possible use to the public, the best way to achieve this is to make it
628free software which everyone can redistribute and change under these terms.
629
630 To do so, attach the following notices to the program. It is safest
631to attach them to the start of each source file to most effectively
632state the exclusion of warranty; and each file should have at least
633the "copyright" line and a pointer to where the full notice is found.
634
635 <one line to give the program's name and a brief idea of what it does.>
636 Copyright (C) <year> <name of author>
637
638 This program is free software: you can redistribute it and/or modify
639 it under the terms of the GNU General Public License as published by
640 the Free Software Foundation, either version 3 of the License, or
641 (at your option) any later version.
642
643 This program is distributed in the hope that it will be useful,
644 but WITHOUT ANY WARRANTY; without even the implied warranty of
645 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
646 GNU General Public License for more details.
647
648 You should have received a copy of the GNU General Public License
649 along with this program. If not, see <http://www.gnu.org/licenses/>.
650
651Also add information on how to contact you by electronic and paper mail.
652
653 If the program does terminal interaction, make it output a short
654notice like this when it starts in an interactive mode:
655
656 <program> Copyright (C) <year> <name of author>
657 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
658 This is free software, and you are welcome to redistribute it
659 under certain conditions; type `show c' for details.
660
661The hypothetical commands `show w' and `show c' should show the appropriate
662parts of the General Public License. Of course, your program's commands
663might be different; for a GUI interface, you would use an "about box".
664
665 You should also get your employer (if you work as a programmer) or school,
666if any, to sign a "copyright disclaimer" for the program, if necessary.
667For more information on this, and how to apply and follow the GNU GPL, see
668<http://www.gnu.org/licenses/>.
669
670 The GNU General Public License does not permit incorporating your program
671into proprietary programs. If your program is a subroutine library, you
672may consider it more useful to permit linking proprietary applications with
673the library. If this is what you want to do, use the GNU Lesser General
674Public License instead of this License. But first, please read
675<http://www.gnu.org/philosophy/why-not-lgpl.html>.
676
0677
=== added file 'doc/COPYING.LESSER'
--- doc/COPYING.LESSER 1970-01-01 00:00:00 +0000
+++ doc/COPYING.LESSER 2010-07-28 20:35:51 +0000
@@ -0,0 +1,165 @@
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8
9 This version of the GNU Lesser General Public License incorporates
10the terms and conditions of version 3 of the GNU General Public
11License, supplemented by the additional permissions listed below.
12
13 0. Additional Definitions.
14
15 As used herein, "this License" refers to version 3 of the GNU Lesser
16General Public License, and the "GNU GPL" refers to version 3 of the GNU
17General Public License.
18
19 "The Library" refers to a covered work governed by this License,
20other than an Application or a Combined Work as defined below.
21
22 An "Application" is any work that makes use of an interface provided
23by the Library, but which is not otherwise based on the Library.
24Defining a subclass of a class defined by the Library is deemed a mode
25of using an interface provided by the Library.
26
27 A "Combined Work" is a work produced by combining or linking an
28Application with the Library. The particular version of the Library
29with which the Combined Work was made is also called the "Linked
30Version".
31
32 The "Minimal Corresponding Source" for a Combined Work means the
33Corresponding Source for the Combined Work, excluding any source code
34for portions of the Combined Work that, considered in isolation, are
35based on the Application, and not on the Linked Version.
36
37 The "Corresponding Application Code" for a Combined Work means the
38object code and/or source code for the Application, including any data
39and utility programs needed for reproducing the Combined Work from the
40Application, but excluding the System Libraries of the Combined Work.
41
42 1. Exception to Section 3 of the GNU GPL.
43
44 You may convey a covered work under sections 3 and 4 of this License
45without being bound by section 3 of the GNU GPL.
46
47 2. Conveying Modified Versions.
48
49 If you modify a copy of the Library, and, in your modifications, a
50facility refers to a function or data to be supplied by an Application
51that uses the facility (other than as an argument passed when the
52facility is invoked), then you may convey a copy of the modified
53version:
54
55 a) under this License, provided that you make a good faith effort to
56 ensure that, in the event an Application does not supply the
57 function or data, the facility still operates, and performs
58 whatever part of its purpose remains meaningful, or
59
60 b) under the GNU GPL, with none of the additional permissions of
61 this License applicable to that copy.
62
63 3. Object Code Incorporating Material from Library Header Files.
64
65 The object code form of an Application may incorporate material from
66a header file that is part of the Library. You may convey such object
67code under terms of your choice, provided that, if the incorporated
68material is not limited to numerical parameters, data structure
69layouts and accessors, or small macros, inline functions and templates
70(ten or fewer lines in length), you do both of the following:
71
72 a) Give prominent notice with each copy of the object code that the
73 Library is used in it and that the Library and its use are
74 covered by this License.
75
76 b) Accompany the object code with a copy of the GNU GPL and this license
77 document.
78
79 4. Combined Works.
80
81 You may convey a Combined Work under terms of your choice that,
82taken together, effectively do not restrict modification of the
83portions of the Library contained in the Combined Work and reverse
84engineering for debugging such modifications, if you also do each of
85the following:
86
87 a) Give prominent notice with each copy of the Combined Work that
88 the Library is used in it and that the Library and its use are
89 covered by this License.
90
91 b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 document.
93
94 c) For a Combined Work that displays copyright notices during
95 execution, include the copyright notice for the Library among
96 these notices, as well as a reference directing the user to the
97 copies of the GNU GPL and this license document.
98
99 d) Do one of the following:
100
101 0) Convey the Minimal Corresponding Source under the terms of this
102 License, and the Corresponding Application Code in a form
103 suitable for, and under terms that permit, the user to
104 recombine or relink the Application with a modified version of
105 the Linked Version to produce a modified Combined Work, in the
106 manner specified by section 6 of the GNU GPL for conveying
107 Corresponding Source.
108
109 1) Use a suitable shared library mechanism for linking with the
110 Library. A suitable mechanism is one that (a) uses at run time
111 a copy of the Library already present on the user's computer
112 system, and (b) will operate properly with a modified version
113 of the Library that is interface-compatible with the Linked
114 Version.
115
116 e) Provide Installation Information, but only if you would otherwise
117 be required to provide such information under section 6 of the
118 GNU GPL, and only to the extent that such information is
119 necessary to install and execute a modified version of the
120 Combined Work produced by recombining or relinking the
121 Application with a modified version of the Linked Version. (If
122 you use option 4d0, the Installation Information must accompany
123 the Minimal Corresponding Source and Corresponding Application
124 Code. If you use option 4d1, you must provide the Installation
125 Information in the manner specified by section 6 of the GNU GPL
126 for conveying Corresponding Source.)
127
128 5. Combined Libraries.
129
130 You may place library facilities that are a work based on the
131Library side by side in a single library together with other library
132facilities that are not Applications and are not covered by this
133License, and convey such a combined library under terms of your
134choice, if you do both of the following:
135
136 a) Accompany the combined library with a copy of the same work based
137 on the Library, uncombined with any other library facilities,
138 conveyed under the terms of this License.
139
140 b) Give prominent notice with the combined library that part of it
141 is a work based on the Library, and explaining where to find the
142 accompanying uncombined form of the same work.
143
144 6. Revised Versions of the GNU Lesser General Public License.
145
146 The Free Software Foundation may publish revised and/or new versions
147of the GNU Lesser General Public License from time to time. Such new
148versions will be similar in spirit to the present version, but may
149differ in detail to address new problems or concerns.
150
151 Each version is given a distinguishing version number. If the
152Library as you received it specifies that a certain numbered version
153of the GNU Lesser General Public License "or any later version"
154applies to it, you have the option of following the terms and
155conditions either of that published version or of any later version
156published by the Free Software Foundation. If the Library as you
157received it does not specify a version number of the GNU Lesser
158General Public License, you may choose any version of the GNU Lesser
159General Public License ever published by the Free Software Foundation.
160
161 If the Library as you received it specifies that a proxy can decide
162whether future versions of the GNU Lesser General Public License shall
163apply, that proxy's public statement of acceptance of any version is
164permanent authorization for you to choose that version for the
165Library.
0166
=== added file 'doc/Makefile'
--- doc/Makefile 1970-01-01 00:00:00 +0000
+++ doc/Makefile 2010-07-28 20:35:51 +0000
@@ -0,0 +1,23 @@
1.PHONY: help clean html text doctest
2
3docs: html text
4
5check: doctest
6
7help:
8 cd src && $(MAKE) $@
9
10html:
11 cd src && $(MAKE) $@
12 cp -r src/_build/html .
13
14text:
15 cd src && $(MAKE) $@
16 cd src && tools/stitch_text.py index.rst _build/text > ../psycopg2.txt
17
18doctest:
19 cd src && $(MAKE) $@
20
21clean:
22 cd src && $(MAKE) $@
23 rm -rf html psycopg2.txt
024
=== added file 'doc/README'
--- doc/README 1970-01-01 00:00:00 +0000
+++ doc/README 2010-07-28 20:35:51 +0000
@@ -0,0 +1,42 @@
1How to build psycopg documentation
2----------------------------------
3
4- Install Sphinx, maybe in a virtualenv. Tested with Sphinx 0.6.4::
5
6 ~$ virtualenv pd
7 New python executable in pd/bin/python
8 Installing setuptools............done.
9 ~$ cd pd
10 ~/pd$ source bin/activate
11 (pd)~/pd$
12
13- Install Sphinx in the env::
14
15 (pd)~/pd$ easy_install sphinx
16 Searching for sphinx
17 Reading http://pypi.python.org/simple/sphinx/
18 Reading http://sphinx.pocoo.org/
19 Best match: Sphinx 0.6.4
20 ...
21 Finished processing dependencies for sphinx
22
23- Build psycopg2 and ensure the package can be imported (it will be used for
24 reading the version number, autodocs etc.)::
25
26 (pd)~/pd/psycopg2$ python setup.py build
27 (pd)~/pd/psycopg2$ python setup.py install
28 running install
29 ...
30 creating ~/pd/lib/python2.6/site-packages/psycopg2
31 ...
32
33- Move to the ``doc`` dir and run ``make`` from there::
34
35 (pd)~/pd/psycopg2$ cd doc/
36 (pd)~/pd/psycopg2/doc$ make
37 Running Sphinx v0.6.4
38 ...
39
40You should have the rendered documentation in ``./html`` and the text file
41``psycopg2.txt`` now.
42
043
=== removed file 'doc/TODO'
--- doc/TODO 2006-08-09 10:28:30 +0000
+++ doc/TODO 1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
1TODO list for psycopg 2 or later
2********************************
3
4Move items to the DONE section only after writing a test for the
5implementation. Also add a note on how the item was resolved.
6(Obviously I was joking about the test..)
7
8* Find a better way to compile the type-casting code instead of including it
9 in typecast.c directy. (Including is not that bad, but the need to touch
10 psycopg/typecast.c every time is bad bad bad.)
11
12* executemany() should _not_ take the async flag, remove it and force multiple
13 queries to be synchronous.
14
15* Fix all the docstrings.
16
17* Support the protocols API fully.
18
19* Unify the common code in typecast_datetime.c and typecast_mxdatetime.c.
20
21* Port typecasters to new-style classes.
22
23* Write a complete postgresql<->python encodings table.
24
25* Implement binary typecasters (should be easy, but it will take time.)
26
27DONE
28====
29
30* Convert type-casters to new-style types in Python 2.2+.
31
32* callproc() never worked, fix it or remove it and raise right exception.
33 [Removed callproc code, now an exception is raised.]
340
=== removed file 'doc/api-screen.css'
--- doc/api-screen.css 2006-08-09 10:28:30 +0000
+++ doc/api-screen.css 1970-01-01 00:00:00 +0000
@@ -1,138 +0,0 @@
1/* Based on the Epydoc "default.css"
2** with some missing reST-related classes
3** and Python syntax support (from SilverCity)
4*/
5
6/* Body color */
7body { background: #ffffff; color: #000000; }
8
9/* Tables */
10table.summary, table.details, table.index
11 { background: #e8f0f8; color: #000000; }
12tr.summary, tr.details, tr.index
13 { background: #70b0f0; color: #000000;
14 text-align: left; font-size: 120%; }
15tr.group { background: #c0e0f8; color: #000000;
16 text-align: left; font-size: 120%;
17 font-style: italic; }
18
19/* Documentation page titles */
20h2.module { margin-top: 0.2em; }
21h2.class { margin-top: 0.2em; }
22
23/* Headings */
24h1.heading { font-size: +140%; font-style: italic;
25 font-weight: bold; }
26h2.heading { font-size: +125%; font-style: italic;
27 font-weight: bold; }
28h3.heading { font-size: +110%; font-style: italic;
29 font-weight: normal; }
30
31/* Base tree */
32pre.base-tree { font-size: 80%; margin: 0; }
33
34/* TOC */
35p.toc { margin: 0; }
36
37/* Details Sections */
38table.func-details { background: #e8f0f8; color: #000000;
39 border: 2px groove #c0d0d0;
40 padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
41h3.func-detail { background: transparent; color: #000000;
42 margin: 0 0 1em 0; }
43
44table.var-details { background: #e8f0f8; color: #000000;
45 border: 2px groove #c0d0d0;
46 padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
47h3.var-details { background: transparent; color: #000000;
48 margin: 0 0 1em 0; }
49
50/* Function signatures */
51.sig { background: transparent; color: #000000;
52 font-weight: bold; }
53.sig-name { background: transparent; color: #006080; }
54.sig-arg, .sig-kwarg, .sig-vararg
55 { background: transparent; color: #008060; }
56.sig-default { background: transparent; color: #602000; }
57.summary-sig { background: transparent; color: #000000; }
58.summary-sig-name { background: transparent; color: #204080; }
59.summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg
60 { background: transparent; color: #008060; }
61
62/* Doctest blocks */
63.py-src { background: transparent; color: #000000; }
64.py-prompt { background: transparent; color: #005050;
65 font-weight: bold;}
66.py-string { background: transparent; color: #006030; }
67.py-comment { background: transparent; color: #003060; }
68.py-keyword { background: transparent; color: #600000; }
69.py-output { background: transparent; color: #404040; }
70div.code-block,
71pre.literal-block,
72pre.doctestblock { background: #f4faff; color: #000000;
73 padding: .5em; margin: 1em;
74 border: 1px solid #708890; }
75table pre.doctestblock
76 { background: #dce4ec; color: #000000;
77 padding: .5em; margin: 1em;
78 border: 1px solid #708890; }
79div.code-block { font-family: monospace; }
80
81/* Variable values */
82pre.variable { background: #dce4ec; color: #000000;
83 padding: .5em; margin: 0;
84 border: 1px solid #708890; }
85.variable-linewrap { background: transparent; color: #604000; }
86.variable-ellipsis { background: transparent; color: #604000; }
87.variable-quote { background: transparent; color: #604000; }
88.re { background: transparent; color: #000000; }
89.re-char { background: transparent; color: #006030; }
90.re-op { background: transparent; color: #600000; }
91.re-group { background: transparent; color: #003060; }
92.re-ref { background: transparent; color: #404040; }
93
94/* Navigation bar */
95table.navbar { background: #a0c0ff; color: #0000ff;
96 border: 2px groove #c0d0d0; }
97th.navbar { background: #a0c0ff; color: #0000ff; }
98th.navselect { background: #70b0ff; color: #000000; }
99.nomargin { margin: 0; }
100
101/* Links */
102a:link { background: transparent; color: #0000ff; }
103a:visited { background: transparent; color: #204080; }
104a.navbar:link { background: transparent; color: #0000ff;
105 text-decoration: none; }
106a.navbar:visited { background: transparent; color: #204080;
107 text-decoration: none; }
108
109/* Admonitions */
110div.warning,
111div.note { background-color: #c0e0f8;
112 border: thin solid black;
113 padding: 1em;
114 margin-left: 1em;
115 margin-right: 1em; }
116div.warning .first,
117div.note .first { font-family: sans-serif;
118 font-size: 110%;
119 margin-right: 0.5em; }
120
121/* Lists */
122ul { margin-top: 0; }
123
124/* Python syntax */
125.p_character { color: olive; }
126.p_classname { color: blue; font-weight: bold; }
127.p_commentblock {color: gray; font-style: italic; }
128.p_commentline { color: green; font-style: italic; }
129.p_default {}
130.p_defname { color: #009999; font-weight: bold; }
131.p_identifier { color: black; }
132.p_number { color: #009999; }
133.p_operator { color: black; }
134.p_string { color: #7F007F; }
135.p_stringeol { color: #7F007F; }
136.p_triple { color: #7F0000; }
137.p_tripledouble { color: #7F0000; }
138.p_word { color: navy; font-weight: bold; }
1390
=== removed file 'doc/async.txt'
--- doc/async.txt 2006-08-09 10:28:30 +0000
+++ doc/async.txt 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
1psycopg asynchronous API
2************************
3
4** Important: async quaeries are not enabled for 2.0 **
5
6Program code can initiate an asynchronous query by passing an 'async=1' flag
7to the .execute() method. A very simple example, from the connection to the
8query:
9
10 conn = psycopg.connect(database='test')
11 curs = conn.cursor()
12 curs.execute("SEECT * from test WHERE fielda > %s", (1971,), async=1)
13
14From then on any query on other cursors derived from the same connection is
15doomed to fail (and raise an exception) until the original cursor (the one
16executing the query) complete the asynchronous operation. This can happen in
17a number of different ways:
18
19 1) one of the .fetchXXX() methods is called, effectively blocking untill
20 data has been sent from the backend to the client, terminating the
21 query.
22
23 2) .cancel() is called. This method tries to abort the current query and
24 will block until the query is aborted or fully executed. The return
25 value is True if the query was successfully aborted or False if it
26 was executed. Query result are discarded in both cases.
27
28 3) .execute() is called again on the same cursor (.execute() on a
29 different cursor will simply raise an exception.) This waits for the
30 complete execution of the current query, discard any data and execute
31 the new one.
32
33Note that calling .execute() two times in a row will not abort the former
34query and will temporarily go to synchronous mode until the first of the two
35queries is executed.
36
37Cursors now have some extra methods that make them usefull during
38asynchronous queries:
39
40 .fileno()
41 Returns the file descriptor associated with the current connection and
42 make possible to use a cursor in a context where a file object would be
43 expected (like in a select() call.)
44
45 .isbusy()
46 Returns True if the backend is still processing the query or false if
47 data is ready to be fetched (by one of the .fetchXXX() methods.)
48
49A code snippet that shows how to use the cursor object in a select() call:
50
51 import psycopg
52 import select
53
54 conn = psycopg.connect(database='test')
55 curs = conn.cursor()
56 curs.execute("SEECT * from test WHERE fielda > %s", (1971,), async=1)
57
58 # wait for input with a maximum timeout of 5 seconds
59 query_ended = False
60 while not query_ended:
61 rread, rwrite, rspec = select([cursor, another_file], [], [], 5)
62 if not cursor.isbusy():
63 query_ended = True
64 # manage input from other sources like other_file, etc.
65 print "Query Results:"
66 for row in cursor:
67 print row
680
=== removed file 'doc/extensions.rst'
--- doc/extensions.rst 2006-08-09 10:28:30 +0000
+++ doc/extensions.rst 1970-01-01 00:00:00 +0000
@@ -1,260 +0,0 @@
1=======================================
2 psycopg 2 extensions to the DBAPI 2.0
3=======================================
4
5This document is a short summary of the extensions built in psycopg 2.0.x over
6the standard `Python Database API Specification 2.0`__, usually called simply
7DBAPI-2.0 or even PEP-249. Before reading on this document please make sure
8you already know how to program in Python using a DBAPI-2.0 compliant driver:
9basic concepts like opening a connection, executing queries and commiting or
10rolling back a transaction will not be explained but just used.
11
12.. __: http://www.python.org/peps/pep-0249.html
13
14Many objects and extension functions are defined in the `psycopg2.extensions`
15module.
16
17
18Connection and cursor factories
19===============================
20
21psycopg 2 exposes two new-style classes that can be sub-classed and expanded to
22adapt them to the needs of the programmer: `cursor` and `connection`. The
23`connection` class is usually sub-classed only to provide an easy way to create
24customized cursors but other uses are possible. `cursor` is much more
25interesting, because it is the class where query building, execution and result
26type-casting into Python variables happens.
27
28An example of cursor subclass performing logging is::
29
30 import psycopg2
31 import psycopg2.extensions
32 import logging
33
34 class LoggingCursor(psycopg2.extensions.cursor):
35 def execute(self, sql, args=None):
36 logger = logging.getLogger('sql_debug')
37 logger.info(self.mogrify(sql, args))
38
39 try:
40 psycopg2.extensions.cursor.execute(self, sql, args)
41 except Exception, exc:
42 logger.error("%s: %s" % (exc.__class__.__name__, exc))
43 raise
44
45 conn = psycopg2.connect(DSN)
46 curs = conn.cursor(cursor_factory=LoggingCursor)
47 curs.execute("INSERT INTO mytable VALUES (%s, %s, %s);",
48 (10, 20, 30))
49
50
51Row factories
52-------------
53
54tzinfo factories
55----------------
56
57
58Setting transaction isolation levels
59====================================
60
61psycopg2 connection objects hold informations about the PostgreSQL `transaction
62isolation level`_. The current transaction level can be read from the
63`.isolation_level` attribute. The default isolation level is ``READ
64COMMITTED``. A different isolation level con be set through the
65`.set_isolation_level()` method. The level can be set to one of the following
66constants, defined in `psycopg2.extensions`:
67
68`ISOLATION_LEVEL_AUTOCOMMIT`
69 No transaction is started when command are issued and no
70 `.commit()`/`.rollback()` is required. Some PostgreSQL command such as
71 ``CREATE DATABASE`` can't run into a transaction: to run such command use
72 `.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)`.
73
74`ISOLATION_LEVEL_READ_COMMITTED`
75 This is the default value. A new transaction is started at the first
76 `.execute()` command on a cursor and at each new `.execute()` after a
77 `.commit()` or a `.rollback()`. The transaction runs in the PostgreSQL
78 ``READ COMMITTED`` isolation level.
79
80`ISOLATION_LEVEL_SERIALIZABLE`
81 Transactions are run at a ``SERIALIZABLE`` isolation level.
82
83
84.. _transaction isolation level:
85 http://www.postgresql.org/docs/8.1/static/transaction-iso.html
86
87
88Adaptation of Python values to SQL types
89========================================
90
91psycopg2 casts Python variables to SQL literals by type. Standard Python types
92are already adapted to the proper SQL literal.
93
94Example: the Python function::
95
96 curs.execute("""INSERT INTO atable (anint, adate, astring)
97 VALUES (%s, %s, %s)""",
98 (10, datetime.date(2005, 11, 18), "O'Reilly"))
99
100is converted into the SQL command::
101
102 INSERT INTO atable (anint, adate, astring)
103 VALUES (10, '2005-11-18', 'O''Reilly');
104
105Named arguments are supported too with ``%(name)s`` placeholders. Notice that:
106
107 - The Python string operator ``%`` is not used: the `.execute()` function
108 accepts the values tuple or dictionary as second parameter.
109
110 - The variables placeholder must always be a ``%s``, even if a different
111 placeholder (such as a ``%d`` for an integer) may look more appropriate.
112
113 - For positional variables binding, the second argument must always be a
114 tuple, even if it contains a single variable.
115
116 - Only variable values should be bound via this method: it shouldn't be used
117 to set table or field names. For these elements, ordinary string formatting
118 should be used before running `.execute()`.
119
120
121Adapting new types
122------------------
123
124Any Python class or type can be adapted to an SQL string. Adaptation mechanism
125is similar to the Object Adaptation proposed in the `PEP-246`_ and is exposed
126by the `adapt()` function.
127
128psycopg2 `.execute()` method adapts its ``vars`` arguments to the `ISQLQuote`
129protocol. Objects that conform to this protocol expose a ``getquoted()`` method
130returning the SQL representation of the object as a string.
131
132The easiest way to adapt an object to an SQL string is to register an adapter
133function via the `register_adapter()` function. The adapter function must take
134the value to be adapted as argument and return a conform object. A convenient
135object is the `AsIs` wrapper, whose ``getquoted()`` result is simply the
136``str()``\ ingification of the wrapped object.
137
138Example: mapping of a ``Point`` class into the ``point`` PostgreSQL geometric
139type::
140
141 from psycopg2.extensions import adapt, register_adapter, AsIs
142
143 class Point(object):
144 def __init__(self, x=0.0, y=0.0):
145 self.x = x
146 self.y = y
147
148 def adapt_point(point):
149 return AsIs("'(%s,%s)'" % (adapt(point.x), adapt(point.y)))
150
151 register_adapter(Point, adapt_point)
152
153 curs.execute("INSERT INTO atable (apoint) VALUES (%s)",
154 (Point(1.23, 4.56),))
155
156The above function call results in the SQL command::
157
158 INSERT INTO atable (apoint) VALUES ((1.23, 4.56));
159
160
161.. _PEP-246: http://www.python.org/peps/pep-0246.html
162
163
164Type casting of SQL types into Python values
165============================================
166
167PostgreSQL objects read from the database can be adapted to Python objects
168through an user-defined adapting function. An adapter function takes two
169argments: the object string representation as returned by PostgreSQL and the
170cursor currently being read, and should return a new Python object. For
171example, the following function parses a PostgreSQL ``point`` into the
172previously defined ``Point`` class::
173
174 def cast_point(value, curs):
175 if value is not None:
176 # Convert from (f1, f2) syntax using a regular expression.
177 m = re.match("\((.*),(.*)\)", value)
178 if m:
179 return Point(float(m.group(1)), float(m.group(2)))
180
181To create a mapping from the PostgreSQL type (either standard or user-defined),
182its ``oid`` must be known. It can be retrieved either by the second column of
183the cursor description::
184
185 curs.execute("SELECT NULL::point")
186 point_oid = curs.description[0][1] # usually returns 600
187
188or by querying the system catalogs for the type name and namespace (the
189namespace for system objects is ``pg_catalog``)::
190
191 curs.execute("""
192 SELECT pg_type.oid
193 FROM pg_type JOIN pg_namespace
194 ON typnamespace = pg_namespace.oid
195 WHERE typname = %(typename)s
196 AND nspname = %(namespace)s""",
197 {'typename': 'point', 'namespace': 'pg_catalog'})
198
199 point_oid = curs.fetchone()[0]
200
201After you know the object ``oid``, you must can and register the new type::
202
203 POINT = psycopg2.extensions.new_type((point_oid,), "POINT", cast_point)
204 psycopg2.extensions.register_type(POINT)
205
206The `new_type()` function binds the object oids (more than one can be
207specified) to the adapter function. `register_type()` completes the spell.
208Conversion is automatically performed when a column whose type is a registered
209``oid`` is read::
210
211 curs.execute("SELECT '(10.2,20.3)'::point")
212 point = curs.fetchone()[0]
213 print type(point), point.x, point.y
214 # Prints: "<class '__main__.Point'> 10.2 20.3"
215
216
217Working with times and dates
218============================
219
220
221Receiving NOTIFYs
222=================
223
224
225Using COPY TO and COPY FROM
226===========================
227
228psycopg2 `cursor` object provides an interface to the efficient `PostgreSQL
229COPY command`__ to move data from files to tables and back.
230
231The `.copy_to(file, table)` method writes the content of the table
232named ``table`` *to* the file-like object ``file``. ``file`` must have a
233``write()`` method.
234
235The `.copy_from(file, table)` reads data *from* the file-like object
236``file`` appending them to the table named ``table``. ``file`` must have both
237``read()`` and ``readline()`` method.
238
239Both methods accept two optional arguments: ``sep`` (defaulting to a tab) is
240the columns separator and ``null`` (defaulting to ``\N``) represents ``NULL``
241values in the file.
242
243.. __: http://www.postgresql.org/docs/8.1/static/sql-copy.html
244
245
246PostgreSQL status message and executed query
247============================================
248
249`cursor` objects have two special fields related to the last executed query:
250
251 - `.query` is the textual representation (str or unicode, depending on what
252 was passed to `.execute()` as first argument) of the query *after* argument
253 binding and mogrification has been applied. To put it another way, `.query`
254 is the *exact* query that was sent to the PostgreSQL backend.
255
256 - `.statusmessage` is the status message that the backend sent upon query
257 execution. It usually contains the basic type of the query (SELECT,
258 INSERT, UPDATE, ...) and some additional information like the number of
259 rows updated and so on. Refer to the PostgreSQL manual for more
260 information.
2610
=== added directory 'doc/html'
=== added file 'doc/html/.buildinfo'
--- doc/html/.buildinfo 1970-01-01 00:00:00 +0000
+++ doc/html/.buildinfo 2010-07-28 20:35:51 +0000
@@ -0,0 +1,4 @@
1# Sphinx build info version 1
2# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3config: 3b2e5d90696feaaf51ed99c8708bfbca
4tags: fbb0d17656682115ca4d033fb2f83ba1
05
=== added directory 'doc/html/_sources'
=== added file 'doc/html/_sources/advanced.txt'
--- doc/html/_sources/advanced.txt 1970-01-01 00:00:00 +0000
+++ doc/html/_sources/advanced.txt 2010-07-28 20:35:51 +0000
@@ -0,0 +1,450 @@
1More advanced topics
2====================
3
4.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
5
6.. testsetup:: *
7
8 import re
9 import select
10
11 cur.execute("CREATE TABLE atable (apoint point)")
12 conn.commit()
13
14 def wait(conn):
15 while 1:
16 state = conn.poll()
17 if state == psycopg2.extensions.POLL_OK:
18 break
19 elif state == psycopg2.extensions.POLL_WRITE:
20 select.select([], [conn.fileno()], [])
21 elif state == psycopg2.extensions.POLL_READ:
22 select.select([conn.fileno()], [], [])
23 else:
24 raise psycopg2.OperationalError("poll() returned %s" % state)
25
26 aconn = psycopg2.connect(database='test', async=1)
27 wait(aconn)
28 acurs = aconn.cursor()
29
30.. index::
31 double: Subclassing; Cursor
32 double: Subclassing; Connection
33
34.. _subclassing-connection:
35.. _subclassing-cursor:
36
37Connection and cursor factories
38-------------------------------
39
40Psycopg exposes two new-style classes that can be sub-classed and expanded to
41adapt them to the needs of the programmer: `psycopg2.extensions.cursor`
42and `psycopg2.extensions.connection`. The `connection` class is
43usually sub-classed only to provide an easy way to create customized cursors
44but other uses are possible. `cursor` is much more interesting, because
45it is the class where query building, execution and result type-casting into
46Python variables happens.
47
48.. index::
49 single: Example; Cursor subclass
50
51An example of cursor subclass performing logging is::
52
53 import psycopg2
54 import psycopg2.extensions
55 import logging
56
57 class LoggingCursor(psycopg2.extensions.cursor):
58 def execute(self, sql, args=None):
59 logger = logging.getLogger('sql_debug')
60 logger.info(self.mogrify(sql, args))
61
62 try:
63 psycopg2.extensions.cursor.execute(self, sql, args)
64 except Exception, exc:
65 logger.error("%s: %s" % (exc.__class__.__name__, exc))
66 raise
67
68 conn = psycopg2.connect(DSN)
69 cur = conn.cursor(cursor_factory=LoggingCursor)
70 cur.execute("INSERT INTO mytable VALUES (%s, %s, %s);",
71 (10, 20, 30))
72
73
74
75.. index::
76 single: Objects; Creating new adapters
77 single: Adaptation; Creating new adapters
78 single: Data types; Creating new adapters
79
80.. _adapting-new-types:
81
82Adapting new Python types to SQL syntax
83---------------------------------------
84
85Any Python class or type can be adapted to an SQL string. Adaptation mechanism
86is similar to the Object Adaptation proposed in the :pep:`246` and is exposed
87by the `psycopg2.extensions.adapt()` function.
88
89The `~cursor.execute()` method adapts its arguments to the
90`~psycopg2.extensions.ISQLQuote` protocol. Objects that conform to this
91protocol expose a `!getquoted()` method returning the SQL representation
92of the object as a string.
93
94The easiest way to adapt an object to an SQL string is to register an adapter
95function via the `~psycopg2.extensions.register_adapter()` function. The
96adapter function must take the value to be adapted as argument and return a
97conform object. A convenient object is the `~psycopg2.extensions.AsIs`
98wrapper, whose `!getquoted()` result is simply the `!str()`\ ing
99conversion of the wrapped object.
100
101.. index::
102 single: Example; Types adaptation
103
104Example: mapping of a `!Point` class into the |point|_ PostgreSQL
105geometric type:
106
107.. doctest::
108
109 >>> from psycopg2.extensions import adapt, register_adapter, AsIs
110
111 >>> class Point(object):
112 ... def __init__(self, x, y):
113 ... self.x = x
114 ... self.y = y
115
116 >>> def adapt_point(point):
117 ... return AsIs("'(%s, %s)'" % (adapt(point.x), adapt(point.y)))
118
119 >>> register_adapter(Point, adapt_point)
120
121 >>> cur.execute("INSERT INTO atable (apoint) VALUES (%s)",
122 ... (Point(1.23, 4.56),))
123
124
125.. |point| replace:: :sql:`point`
126.. _point: http://www.postgresql.org/docs/8.4/static/datatype-geometric.html#AEN6084
127
128The above function call results in the SQL command::
129
130 INSERT INTO atable (apoint) VALUES ((1.23, 4.56));
131
132
133
134.. index:: Type casting
135
136.. _type-casting-from-sql-to-python:
137
138Type casting of SQL types into Python objects
139---------------------------------------------
140
141PostgreSQL objects read from the database can be adapted to Python objects
142through an user-defined adapting function. An adapter function takes two
143arguments: the object string representation as returned by PostgreSQL and the
144cursor currently being read, and should return a new Python object. For
145example, the following function parses the PostgreSQL :sql:`point`
146representation into the previously defined `!Point` class:
147
148 >>> def cast_point(value, cur):
149 ... if value is None:
150 ... return None
151 ...
152 ... # Convert from (f1, f2) syntax using a regular expression.
153 ... m = re.match(r"\(([^)]+),([^)]+)\)", value)
154 ... if m:
155 ... return Point(float(m.group(1)), float(m.group(2)))
156 ... else:
157 ... raise InterfaceError("bad point representation: %r" % value)
158
159
160In order to create a mapping from a PostgreSQL type (either standard or
161user-defined), its OID must be known. It can be retrieved either by the second
162column of the `cursor.description`:
163
164 >>> cur.execute("SELECT NULL::point")
165 >>> point_oid = cur.description[0][1]
166 >>> point_oid
167 600
168
169or by querying the system catalog for the type name and namespace (the
170namespace for system objects is :sql:`pg_catalog`):
171
172 >>> cur.execute("""
173 ... SELECT pg_type.oid
174 ... FROM pg_type JOIN pg_namespace
175 ... ON typnamespace = pg_namespace.oid
176 ... WHERE typname = %(typename)s
177 ... AND nspname = %(namespace)s""",
178 ... {'typename': 'point', 'namespace': 'pg_catalog'})
179 >>> point_oid = cur.fetchone()[0]
180 >>> point_oid
181 600
182
183After you know the object OID, you can create and register the new type:
184
185 >>> POINT = psycopg2.extensions.new_type((point_oid,), "POINT", cast_point)
186 >>> psycopg2.extensions.register_type(POINT)
187
188The `~psycopg2.extensions.new_type()` function binds the object OIDs
189(more than one can be specified) to the adapter function.
190`~psycopg2.extensions.register_type()` completes the spell. Conversion
191is automatically performed when a column whose type is a registered OID is
192read:
193
194 >>> cur.execute("SELECT '(10.2,20.3)'::point")
195 >>> point = cur.fetchone()[0]
196 >>> print type(point), point.x, point.y
197 <class 'Point'> 10.2 20.3
198
199
200
201.. index::
202 pair: Asynchronous; Notifications
203 pair: LISTEN; SQL command
204 pair: NOTIFY; SQL command
205
206.. _async-notify:
207
208Asynchronous notifications
209--------------------------
210
211Psycopg allows asynchronous interaction with other database sessions using the
212facilities offered by PostgreSQL commands |LISTEN|_ and |NOTIFY|_. Please
213refer to the PostgreSQL documentation for examples of how to use this form of
214communications.
215
216Notifications received are made available in the `connection.notifies`
217list. Notifications can be sent from Python code simply using a :sql:`NOTIFY`
218command in an `~cursor.execute()` call.
219
220Because of the way sessions interact with notifications (see |NOTIFY|_
221documentation), you should keep the connection in :ref:`autocommit
222<autocommit>` mode if you wish to receive or send notifications in a timely
223manner.
224
225.. |LISTEN| replace:: :sql:`LISTEN`
226.. _LISTEN: http://www.postgresql.org/docs/8.4/static/sql-listen.html
227.. |NOTIFY| replace:: :sql:`NOTIFY`
228.. _NOTIFY: http://www.postgresql.org/docs/8.4/static/sql-notify.html
229
230Notification are received after every query execution. If the user is interested
231in receiving notification but not in performing any query, the
232`~connection.poll()` method can be used to check for notification without
233wasting resources.
234
235A simple application could poll the connection from time to time to check if
236something new has arrived. A better strategy is to use some I/O completion
237function such as |select()|_ to sleep until awaken from the kernel when there is
238some data to read on the connection, thereby using no CPU unless there is
239something to read::
240
241 import select
242 import psycopg2
243 import psycopg2.extensions
244
245 conn = psycopg2.connect(DSN)
246 conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
247
248 curs = conn.cursor()
249 curs.execute("LISTEN test;")
250
251 print "Waiting for 'NOTIFY test'"
252 while 1:
253 if select.select([conn],[],[],5) == ([],[],[]):
254 print "Timeout"
255 else:
256 conn.poll()
257 while conn.notifies:
258 print "Got NOTIFY:", conn.notifies.pop()
259
260Running the script and executing the command :sql:`NOTIFY test` in a separate
261:program:`psql` shell, the output may look similar to::
262
263 Waiting for 'NOTIFY test'
264 Timeout
265 Timeout
266 Got NOTIFY: (6535, 'test')
267 Timeout
268 ...
269
270
271
272.. index::
273 double: Asynchronous; Connection
274
275.. _async-support:
276
277Asynchronous support
278--------------------
279
280.. versionadded:: 2.2.0
281
282Psycopg can issue asynchronous queries to a PostgreSQL database. An asynchronous
283communication style is established passing the parameter *async*\=1 to the
284`~psycopg2.connect()` function: the returned connection will work in
285*asynchronous mode*.
286
287In asynchronous mode, a Psycopg connection will rely on the caller to poll the
288socket file descriptor, checking if it is ready to accept data or if a query
289result has been transferred and is ready to be read on the client. The caller
290can use the method `~connection.fileno()` to get the connection file
291descriptor and `~connection.poll()` to make communication proceed according to
292the current connection state.
293
294The following is an example loop using methods `!fileno()` and `!poll()`
295together with the Python |select()|_ function in order to carry on
296asynchronous operations with Psycopg::
297
298 def wait(conn):
299 while 1:
300 state = conn.poll()
301 if state == psycopg2.extensions.POLL_OK:
302 break
303 elif state == psycopg2.extensions.POLL_WRITE:
304 select.select([], [conn.fileno()], [])
305 elif state == psycopg2.extensions.POLL_READ:
306 select.select([conn.fileno()], [], [])
307 else:
308 raise psycopg2.OperationalError("poll() returned %s" % state)
309
310.. |select()| replace:: `!select()`
311.. _select(): http://docs.python.org/library/select.html#select.select
312
313The above loop of course would block an entire application: in a real
314asynchronous framework, `!select()` would be called on many file descriptors
315waiting for any of them to be ready. Nonetheless the function can be used to
316connect to a PostgreSQL server only using nonblocking commands and the
317connection obtained can be used to perform further nonblocking queries. After
318`!poll()` has returned `~psycopg2.extensions.POLL_OK`, and thus `!wait()` has
319returned, the connection can be safely used:
320
321 >>> aconn = psycopg2.connect(database='test', async=1)
322 >>> wait(aconn)
323 >>> acurs = aconn.cursor()
324
325Notice that there are a few other requirements to be met in order to have a
326completely non-blocking connection attempt: see the libpq documentation for
327|PQconnectStart|_.
328
329.. |PQconnectStart| replace:: `!PQconnectStart()`
330.. _PQconnectStart: http://www.postgresql.org/docs/8.4/static/libpq-connect.html#AEN33199
331
332The same loop should be also used to perform nonblocking queries: after
333sending a query via `~cursor.execute()` or `~cursor.callproc()`, call
334`!poll()` on the connection available from `cursor.connection` until it
335returns `!POLL_OK`, at which pont the query has been completely sent to the
336server and, if it produced data, the results have been transferred to the
337client and available using the regular cursor methods:
338
339 >>> acurs.execute("SELECT pg_sleep(5); SELECT 42;")
340 >>> wait(acurs.connection)
341 >>> acurs.fetchone()[0]
342 42
343
344When an asynchronous query is being executed, `connection.isexecuting()` returns
345`True`. Two cursors can't execute concurrent queries on the same asynchronous
346connection.
347
348There are several limitations in using asynchronous connections: the
349connection is always in :ref:`autocommit <autocommit>` mode and it is not
350possible to change it using `~connection.set_isolation_level()`. So a
351transaction is not implicitly started at the first query and is not possible
352to use methods `~connection.commit()` and `~connection.rollback()`: you can
353manually control transactions using `~cursor.execute()` to send database
354commands such as :sql:`BEGIN`, :sql:`COMMIT` and :sql:`ROLLBACK`.
355
356With asynchronous connections it is also not possible to use
357`~connection.set_client_encoding()`, `~cursor.executemany()`, :ref:`large
358objects <large-objects>`, :ref:`named cursors <server-side-cursors>`.
359
360:ref:`COPY commands <copy>` are not supported either in asynchronous mode, but
361this will be probably implemented in a future release.
362
363
364
365
366.. index::
367 single: Greenlet, Coroutine, Eventlet, gevent, Wait callback
368
369.. _green-support:
370
371Support to coroutine libraries
372------------------------------
373
374.. versionadded:: 2.2.0
375
376Psycopg can be used together with coroutine_\-based libraries, and participate
377to cooperative multithreading.
378
379Coroutine-based libraries (such as Eventlet_ or gevent_) can usually patch the
380Python standard library in order to enable a coroutine switch in the presence of
381blocking I/O: the process is usually referred as making the system *green*, in
382reference to the `green threads`_.
383
384Because Psycopg is a C extension module, it is not possible for coroutine
385libraries to patch it: Psycopg instead enables cooperative multithreading by
386allowing the registration of a *wait callback* using the
387`psycopg2.extensions.set_wait_callback()` function. When a wait callback is
388registered, Psycopg will use `libpq non-blocking calls`__ instead of the regular
389blocking ones, and will delegate to the callback the responsibility to wait
390for the socket to become readable or writable.
391
392Working this way, the caller does not have the complete freedom to schedule the
393socket check whenever they want as with an :ref:`asynchronous connection
394<async-support>`, but has the advantage of maintaining a complete |DBAPI|
395semantics: from the point of view of the end user, all Psycopg functions and
396objects will work transparently in the coroutine environment (blocking the
397calling green thread and giving other green threads the possibility to be
398scheduled), allowing non modified code and third party libraries (such as
399SQLAlchemy_) to be used in coroutine-based programs.
400
401Notice that, while I/O correctly yields control to other coroutines, each
402connection has a lock allowing a single cursor at a time to communicate with the
403backend: such lock is not *green*, so blocking against it would block the
404entire program waiting for data, not the single coroutine. Therefore,
405programmers are advised to either avoid sharing connections between coroutines
406or to use a library-friendly lock to synchronize shared connections, e.g. for
407pooling.
408
409Coroutine libraries authors should provide a callback implementation (and
410probably register it) to make Psycopg as green as they want. An example
411callback (using `!select()` to block) is provided as
412`psycopg2.extras.wait_select()`: it boils down to something similar to::
413
414 def wait_select(conn):
415 while 1:
416 state = conn.poll()
417 if state == extensions.POLL_OK:
418 break
419 elif state == extensions.POLL_READ:
420 select.select([conn.fileno()], [], [])
421 elif state == extensions.POLL_WRITE:
422 select.select([], [conn.fileno()], [])
423 else:
424 raise OperationalError("bad state from poll: %s" % state)
425
426.. _coroutine: http://en.wikipedia.org/wiki/Coroutine
427.. _greenlet: http://pypi.python.org/pypi/greenlet
428.. _green threads: http://en.wikipedia.org/wiki/Green_threads
429.. _Eventlet: http://eventlet.net/
430.. _gevent: http://www.gevent.org/
431.. _SQLAlchemy: http://www.sqlalchemy.org/
432.. __: http://www.postgresql.org/docs/8.4/static/libpq-async.html
433
434.. warning::
435 :ref:`COPY commands <copy>` are currently not supported when a wait callback
436 is registered, but they will be probably implemented in a future release.
437
438 :ref:`Large objects <large-objects>` are not supported either: they are
439 not compatible with asynchronous connections.
440
441
442.. testcode::
443 :hide:
444
445 aconn.close()
446 conn.rollback()
447 cur.execute("DROP TABLE atable")
448 conn.commit()
449 cur.close()
450 conn.close()
0451
=== added file 'doc/html/_sources/connection.txt'
--- doc/html/_sources/connection.txt 1970-01-01 00:00:00 +0000
+++ doc/html/_sources/connection.txt 2010-07-28 20:35:51 +0000
@@ -0,0 +1,365 @@
1The ``connection`` class
2========================
3
4.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
5
6.. testsetup::
7
8 from pprint import pprint
9 import psycopg2.extensions
10
11 drop_test_table('foo')
12
13.. class:: connection
14
15 Handles the connection to a PostgreSQL database instance. It encapsulates
16 a database session.
17
18 Connections are created using the factory function
19 `~psycopg2.connect()`.
20
21 Connections are thread safe and can be shared among many thread. See
22 :ref:`thread-safety` for details.
23
24 .. method:: cursor([name] [, cursor_factory])
25
26 Return a new `cursor` object using the connection.
27
28 If `name` is specified, the returned cursor will be a *server
29 side* (or *named*) cursor. Otherwise the cursor will be *client side*.
30 See :ref:`server-side-cursors` for further details.
31
32 The `cursor_factory` argument can be used to create non-standard
33 cursors. The class returned should be a subclass of
34 `psycopg2.extensions.cursor`. See :ref:`subclassing-cursor` for
35 details.
36
37 .. extension::
38
39 The `name` and `cursor_factory` parameters are Psycopg
40 extensions to the |DBAPI|.
41
42
43 .. index::
44 pair: Transaction; Commit
45
46 .. method:: commit()
47
48 Commit any pending transaction to the database. Psycopg can be set to
49 perform automatic commits at each operation, see
50 `~connection.set_isolation_level()`.
51
52
53 .. index::
54 pair: Transaction; Rollback
55
56 .. method:: rollback()
57
58 Roll back to the start of any pending transaction. Closing a
59 connection without committing the changes first will cause an implicit
60 rollback to be performed.
61
62
63 .. method:: close()
64
65 Close the connection now (rather than whenever `__del__()` is
66 called). The connection will be unusable from this point forward; an
67 `~psycopg2.InterfaceError` will be raised if any operation is
68 attempted with the connection. The same applies to all cursor objects
69 trying to use the connection. Note that closing a connection without
70 committing the changes first will cause an implicit rollback to be
71 performed (unless a different isolation level has been selected: see
72 `~connection.set_isolation_level()`).
73
74
75 .. index::
76 single: Exceptions; In the connection class
77
78 .. rubric:: Excetptions as connection class attributes
79
80 The `!connection` also exposes as attributes the same exceptions
81 available in the `psycopg2` module. See :ref:`dbapi-exceptions`.
82
83
84 .. extension::
85
86 The above methods are the only ones defined by the |DBAPI| protocol.
87 The Psycopg connection objects exports the following additional
88 methods and attributes.
89
90
91 .. attribute:: closed
92
93 Read-only attribute reporting whether the database connection is open
94 (0) or closed (1).
95
96
97 .. method:: reset
98
99 Reset the connection to the default.
100
101 The method rolls back an eventual pending transaction and executes the
102 PostgreSQL |RESET|_ and |SET SESSION AUTHORIZATION|__ to revert the
103 session to the default values.
104
105 .. |RESET| replace:: :sql:`RESET`
106 .. _RESET: http://www.postgresql.org/docs/8.4/static/sql-reset.html
107
108 .. |SET SESSION AUTHORIZATION| replace:: :sql:`SET SESSION AUTHORIZATION`
109 .. __: http://www.postgresql.org/docs/8.4/static/sql-set-session-authorization.html
110
111 .. versionadded:: 2.0.12
112
113
114 .. attribute:: dsn
115
116 Read-only string containing the connection string used by the
117 connection.
118
119
120 .. index::
121 pair: Transaction; Autocommit
122 pair: Transaction; Isolation level
123
124 .. _autocommit:
125
126 .. attribute:: isolation_level
127 .. method:: set_isolation_level(level)
128
129 Read or set the `transaction isolation level`_ for the current session.
130 The level defines the different phenomena that can happen in the
131 database between concurrent transactions.
132
133 The value set or read is an integer: symbolic constants are defined in
134 the module `psycopg2.extensions`: see
135 :ref:`isolation-level-constants` for the available values.
136
137 The default level is :sql:`READ COMMITTED`: at this level a
138 transaction is automatically started the first time a database command
139 is executed. If you want an *autocommit* mode, switch to
140 `~psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT` before
141 executing any command::
142
143 >>> conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
144
145 See also :ref:`transactions-control`.
146
147 .. index::
148 pair: Client; Encoding
149
150 .. attribute:: encoding
151 .. method:: set_client_encoding(enc)
152
153 Read or set the client encoding for the current session. The default
154 is the encoding defined by the database. It should be one of the
155 `characters set supported by PostgreSQL`__
156
157 .. __: http://www.postgresql.org/docs/8.4/static/multibyte.html
158
159
160 .. index::
161 pair: Client; Logging
162
163 .. attribute:: notices
164
165 A list containing all the database messages sent to the client during
166 the session.
167
168 .. doctest::
169 :options: NORMALIZE_WHITESPACE
170
171 >>> cur.execute("CREATE TABLE foo (id serial PRIMARY KEY);")
172 >>> pprint(conn.notices)
173 ['NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"\n',
174 'NOTICE: CREATE TABLE will create implicit sequence "foo_id_seq" for serial column "foo.id"\n']
175
176 To avoid a leak in case excessive notices are generated, only the last
177 50 messages are kept.
178
179 You can configure what messages to receive using `PostgreSQL logging
180 configuration parameters`__ such as ``log_statement``,
181 ``client_min_messages``, ``log_min_duration_statement`` etc.
182
183 .. __: http://www.postgresql.org/docs/8.4/static/runtime-config-logging.html
184
185
186 .. attribute:: notifies
187
188 List containing asynchronous notifications received by the session.
189
190 Received notifications have the form of a 2 items tuple
191 :samp:`({pid},{name})`, where :samp:`{pid}` is the PID of the backend
192 that sent the notification and :samp:`{name}` is the signal name
193 specified in the :sql:`NOTIFY` command.
194
195 For other details see :ref:`async-notify`.
196
197 .. index::
198 pair: Backend; PID
199
200 .. method:: get_backend_pid()
201
202 Returns the process ID (PID) of the backend server process handling
203 this connection.
204
205 Note that the PID belongs to a process executing on the database
206 server host, not the local host!
207
208 .. seealso:: libpq docs for `PQbackendPID()`__ for details.
209
210 .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33590
211
212 .. versionadded:: 2.0.8
213
214
215 .. index::
216 pair: Server; Parameters
217
218 .. method:: get_parameter_status(parameter)
219
220 Look up a current parameter setting of the server.
221
222 Potential values for ``parameter`` are: ``server_version``,
223 ``server_encoding``, ``client_encoding``, ``is_superuser``,
224 ``session_authorization``, ``DateStyle``, ``TimeZone``,
225 ``integer_datetimes``, and ``standard_conforming_strings``.
226
227 If server did not report requested parameter, return ``None``.
228
229 .. seealso:: libpq docs for `PQparameterStatus()`__ for details.
230
231 .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33499
232
233 .. versionadded:: 2.0.12
234
235
236 .. index::
237 pair: Transaction; Status
238
239 .. method:: get_transaction_status()
240
241 Return the current session transaction status as an integer. Symbolic
242 constants for the values are defined in the module
243 `psycopg2.extensions`: see :ref:`transaction-status-constants`
244 for the available values.
245
246 .. seealso:: libpq docs for `PQtransactionStatus()`__ for details.
247
248 .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33480
249
250
251 .. index::
252 pair: Protocol; Version
253
254 .. attribute:: protocol_version
255
256 A read-only integer representing frontend/backend protocol being used.
257 It can be 2 or 3.
258
259 .. seealso:: libpq docs for `PQprotocolVersion()`__ for details.
260
261 .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33546
262
263 .. versionadded:: 2.0.12
264
265
266 .. index::
267 pair: Server; Version
268
269 .. attribute:: server_version
270
271 A read-only integer representing the backend version.
272
273 The number is formed by converting the major, minor, and revision
274 numbers into two-decimal-digit numbers and appending them together.
275 For example, version 8.1.5 will be returned as ``80105``.
276
277 .. seealso:: libpq docs for `PQserverVersion()`__ for details.
278
279 .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33556
280
281 .. versionadded:: 2.0.12
282
283
284 .. index::
285 pair: Connection; Status
286
287 .. attribute:: status
288
289 A read-only integer representing the status of the connection.
290 Symbolic constants for the values are defined in the module
291 `psycopg2.extensions`: see :ref:`connection-status-constants`
292 for the available values.
293
294
295 .. method:: lobject([oid [, mode [, new_oid [, new_file [, lobject_factory]]]]])
296
297 Return a new database large object. See :ref:`large-objects` for an
298 overview.
299
300 :param oid: The OID of the object to read or write. 0 to create
301 a new large object and and have its OID assigned automatically.
302 :param mode: Access mode to the object: can be ``r``, ``w``,
303 ``rw`` or ``n`` (meaning don't open it).
304 :param new_oid: Create a new object using the specified OID. The
305 function raises `OperationalError` if the OID is already in
306 use. Default is 0, meaning assign a new one automatically.
307 :param new_file: The name of a file to be imported in the the database
308 (using the |lo_import|_ function)
309 :param lobject_factory: Subclass of
310 `~psycopg2.extensions.lobject` to be instantiated.
311 :rtype: `~psycopg2.extensions.lobject`
312
313 .. |lo_import| replace:: `!lo_import()`
314 .. _lo_import: http://www.postgresql.org/docs/8.4/static/lo-interfaces.html#AEN36307
315
316 .. versionadded:: 2.0.8
317
318
319
320 .. rubric:: Methods related to asynchronous support.
321
322 .. versionadded:: 2.2.0
323
324 .. seealso:: :ref:`async-support` and :ref:`green-support`.
325
326
327 .. attribute:: async
328
329 Read only attribute: 1 if the connection is asynchronous, 0 otherwse.
330
331
332 .. method:: poll()
333
334 Used during an asynchronous connection attempt, or when a cursor is
335 executing a query on an asynchronous connection, make communication
336 proceed if it wouldn't block.
337
338 Return one of the constants defined in :ref:`poll-constants`. If it
339 returns `~psycopg2.extensions.POLL_OK` then the connection has been
340 estabilished or the query results are available on the client.
341 Otherwise wait until the file descriptor returned by `fileno()` is
342 ready to read or to write, as explained in :ref:`async-support`.
343 `poll()` should be also used by the function installed by
344 `~psycopg2.extensions.set_wait_callback()` as explained in
345 :ref:`green-support`.
346
347 `poll()` is also used to receive asynchronous notifications from the
348 database: see :ref:`async-notify` from further details.
349
350
351 .. method:: fileno()
352
353 Return the file descriptor underlying the connection: useful to read
354 its status during asynchronous communication.
355
356
357 .. method:: isexecuting()
358
359 Return `True` if the connection is executing an asynchronous operation.
360
361
362.. testcode::
363 :hide:
364
365 conn.rollback()
0366
=== added file 'doc/html/_sources/cursor.txt'
--- doc/html/_sources/cursor.txt 1970-01-01 00:00:00 +0000
+++ doc/html/_sources/cursor.txt 2010-07-28 20:35:51 +0000
@@ -0,0 +1,473 @@
1The ``cursor`` class
2====================
3
4.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
5
6.. testsetup:: *
7
8 from StringIO import StringIO
9 import sys
10
11 create_test_table()
12
13 # initial data
14 cur.executemany("INSERT INTO test (num, data) VALUES (%s, %s)",
15 [(100, "abc'def"), (None, 'dada'), (42, 'bar')])
16 conn.commit()
17
18
19.. class:: cursor
20
21 Allows Python code to execute PostgreSQL command in a database session.
22 Cursors are created by the `connection.cursor()` method: they are
23 bound to the connection for the entire lifetime and all the commands are
24 executed in the context of the database session wrapped by the connection.
25
26 Cursors created from the same connection are not isolated, i.e., any
27 changes done to the database by a cursor are immediately visible by the
28 other cursors. Cursors created from different connections can or can not
29 be isolated, depending on the connections' :ref:`isolation level
30 <transactions-control>`. See also `~connection.rollback()` and
31 `~connection.commit()` methods.
32
33 Cursors are *not* thread safe: a multithread application can create
34 many cursors from the same connection and should use each cursor from
35 a single thread. See :ref:`thread-safety` for details.
36
37
38 .. attribute:: description
39
40 This read-only attribute is a sequence of 7-item sequences.
41
42 Each of these sequences contains information describing one result
43 column:
44
45 - ``name``
46 - ``type_code``
47 - ``display_size``
48 - ``internal_size``
49 - ``precision``
50 - ``scale``
51 - ``null_ok``
52
53 The first two items (``name`` and ``type_code``) are always specified,
54 the other five are optional and are set to ``None`` if no meaningful
55 values can be provided.
56
57 This attribute will be ``None`` for operations that do not return rows
58 or if the cursor has not had an operation invoked via the
59 |execute*|_ methods yet.
60
61 The ``type_code`` can be interpreted by comparing it to the Type
62 Objects specified in the section :ref:`type-objects-and-constructors`.
63 It is also used to register typecasters to convert PostgreSQL types to
64 Python objects: see :ref:`type-casting-from-sql-to-python`.
65
66
67 .. method:: close()
68
69 Close the cursor now (rather than whenever `!__del__()` is
70 called). The cursor will be unusable from this point forward; an
71 `~psycopg2.InterfaceError` will be raised if any operation is
72 attempted with the cursor.
73
74 .. attribute:: closed
75
76 Read-only boolean attribute: specifies if the cursor is closed
77 (``True``) or not (``False``).
78
79 .. extension::
80
81 The `closed` attribute is a Psycopg extension to the
82 |DBAPI|.
83
84 .. versionadded:: 2.0.7
85
86
87 .. attribute:: connection
88
89 Read-only attribute returning a reference to the `connection`
90 object on which the cursor was created.
91
92
93 .. attribute:: name
94
95 Read-only attribute containing the name of the cursor if it was
96 creates as named cursor by `connection.cursor()`, or ``None`` if
97 it is a client side cursor. See :ref:`server-side-cursors`.
98
99 .. extension::
100
101 The `name` attribute is a Psycopg extension to the |DBAPI|.
102
103
104
105 .. |execute*| replace:: `execute*()`
106
107 .. _execute*:
108
109 .. rubric:: Commands execution methods
110
111
112 .. method:: execute(operation [, parameters])
113
114 Prepare and execute a database operation (query or command).
115
116 Parameters may be provided as sequence or mapping and will be bound to
117 variables in the operation. Variables are specified either with
118 positional (``%s``) or named (:samp:`%({name})s`) placeholders. See
119 :ref:`query-parameters`.
120
121 The method returns `None`. If a query was executed, the returned
122 values can be retrieved using |fetch*|_ methods.
123
124
125 .. method:: mogrify(operation [, parameters])
126
127 Return a query string after arguments binding. The string returned is
128 exactly the one that would be sent to the database running the
129 `~cursor.execute()` method or similar.
130
131 >>> cur.mogrify("INSERT INTO test (num, data) VALUES (%s, %s)", (42, 'bar'))
132 "INSERT INTO test (num, data) VALUES (42, E'bar')"
133
134 .. extension::
135
136 The `mogrify()` method is a Psycopg extension to the |DBAPI|.
137
138
139 .. method:: executemany(operation, seq_of_parameters)
140
141 Prepare a database operation (query or command) and then execute it
142 against all parameter tuples or mappings found in the sequence
143 `seq_of_parameters`.
144
145 The function is mostly useful for commands that update the database:
146 any result set returned by the query is discarded.
147
148 Parameters are bounded to the query using the same rules described in
149 the `~cursor.execute()` method.
150
151
152 .. method:: callproc(procname [, parameters])
153
154 Call a stored database procedure with the given name. The sequence of
155 parameters must contain one entry for each argument that the procedure
156 expects. The result of the call is returned as modified copy of the
157 input sequence. Input parameters are left untouched, output and
158 input/output parameters replaced with possibly new values.
159
160 The procedure may also provide a result set as output. This must then
161 be made available through the standard |fetch*|_ methods.
162
163
164 .. method:: setinputsizes(sizes)
165
166 This method is exposed in compliance with the |DBAPI|. It currently
167 does nothing but it is safe to call it.
168
169
170
171 .. |fetch*| replace:: `!fetch*()`
172
173 .. _fetch*:
174
175 .. rubric:: Results retrieval methods
176
177
178 The following methods are used to read data from the database after an
179 `~cursor.execute()` call.
180
181 .. _cursor-iterable:
182
183 .. note::
184
185 `cursor` objects are iterable, so, instead of calling
186 explicitly `~cursor.fetchone()` in a loop, the object itself can
187 be used:
188
189 >>> cur.execute("SELECT * FROM test;")
190 >>> for record in cur:
191 ... print record
192 ...
193 (1, 100, "abc'def")
194 (2, None, 'dada')
195 (3, 42, 'bar')
196
197
198 .. method:: fetchone()
199
200 Fetch the next row of a query result set, returning a single tuple,
201 or ``None`` when no more data is available:
202
203 >>> cur.execute("SELECT * FROM test WHERE id = %s", (3,))
204 >>> cur.fetchone()
205 (3, 42, 'bar')
206
207 A `~psycopg2.ProgrammingError` is raised if the previous call
208 to |execute*|_ did not produce any result set or no call was issued
209 yet.
210
211
212 .. method:: fetchmany([size=cursor.arraysize])
213
214 Fetch the next set of rows of a query result, returning a list of
215 tuples. An empty list is returned when no more rows are available.
216
217 The number of rows to fetch per call is specified by the parameter.
218 If it is not given, the cursor's `~cursor.arraysize` determines
219 the number of rows to be fetched. The method should try to fetch as
220 many rows as indicated by the size parameter. If this is not possible
221 due to the specified number of rows not being available, fewer rows
222 may be returned:
223
224 >>> cur.execute("SELECT * FROM test;")
225 >>> cur.fetchmany(2)
226 [(1, 100, "abc'def"), (2, None, 'dada')]
227 >>> cur.fetchmany(2)
228 [(3, 42, 'bar')]
229 >>> cur.fetchmany(2)
230 []
231
232 A `~psycopg2.ProgrammingError` is raised if the previous call to
233 |execute*|_ did not produce any result set or no call was issued yet.
234
235 Note there are performance considerations involved with the size
236 parameter. For optimal performance, it is usually best to use the
237 `~cursor.arraysize` attribute. If the size parameter is used,
238 then it is best for it to retain the same value from one
239 `fetchmany()` call to the next.
240
241
242 .. method:: fetchall()
243
244 Fetch all (remaining) rows of a query result, returning them as a list
245 of tuples. An empty list is returned if there is no more record to
246 fetch.
247
248 >>> cur.execute("SELECT * FROM test;")
249 >>> cur.fetchall()
250 [(1, 100, "abc'def"), (2, None, 'dada'), (3, 42, 'bar')]
251
252 A `~psycopg2.ProgrammingError` is raised if the previous call to
253 |execute*|_ did not produce any result set or no call was issued yet.
254
255
256 .. method:: scroll(value [, mode='relative'])
257
258 Scroll the cursor in the result set to a new position according
259 to mode.
260
261 If `mode` is ``relative`` (default), value is taken as offset to
262 the current position in the result set, if set to ``absolute``,
263 value states an absolute target position.
264
265 If the scroll operation would leave the result set, a
266 `~psycopg2.ProgrammingError` is raised and the cursor position is
267 not changed.
268
269 The method can be used both for client-side cursors and
270 :ref:`server-side cursors <server-side-cursors>`.
271
272 .. note::
273
274 According to the |DBAPI|_, the exception raised for a cursor out
275 of bound should have been `!IndexError`. The best option is
276 probably to catch both exceptions in your code::
277
278 try:
279 cur.scroll(1000 * 1000)
280 except (ProgrammingError, IndexError), exc:
281 deal_with_it(exc)
282
283
284 .. attribute:: arraysize
285
286 This read/write attribute specifies the number of rows to fetch at a
287 time with `~cursor.fetchmany()`. It defaults to 1 meaning to fetch
288 a single row at a time.
289
290
291 .. attribute:: rowcount
292
293 This read-only attribute specifies the number of rows that the last
294 |execute*|_ produced (for :abbr:`DQL (Data Query Language)` statements
295 like :sql:`SELECT`) or affected (for
296 :abbr:`DML (Data Manipulation Language)` statements like :sql:`UPDATE`
297 or :sql:`INSERT`).
298
299 The attribute is -1 in case no |execute*| has been performed on
300 the cursor or the row count of the last operation if it can't be
301 determined by the interface.
302
303 .. note::
304 The |DBAPI|_ interface reserves to redefine the latter case to
305 have the object return ``None`` instead of -1 in future versions
306 of the specification.
307
308
309 .. attribute:: rownumber
310
311 This read-only attribute provides the current 0-based index of the
312 cursor in the result set or ``None`` if the index cannot be
313 determined.
314
315 The index can be seen as index of the cursor in a sequence (the result
316 set). The next fetch operation will fetch the row indexed by
317 `rownumber` in that sequence.
318
319
320 .. index:: oid
321
322 .. attribute:: lastrowid
323
324 This read-only attribute provides the OID of the last row inserted
325 by the cursor. If the table wasn't created with OID support or the
326 last operation is not a single record insert, the attribute is set to
327 ``None``.
328
329 PostgreSQL currently advices to not create OIDs on the tables and the
330 default for |CREATE-TABLE|__ is to not support them. The
331 |INSERT-RETURNING|__ syntax available from PostgreSQL 8.3 allows more
332 flexibility.
333
334 .. |CREATE-TABLE| replace:: :sql:`CREATE TABLE`
335 .. __: http://www.postgresql.org/docs/8.4/static/sql-createtable.html
336
337 .. |INSERT-RETURNING| replace:: :sql:`INSERT ... RETURNING`
338 .. __: http://www.postgresql.org/docs/8.4/static/sql-insert.html
339
340
341 .. method:: nextset()
342
343 This method is not supported (PostgreSQL does not have multiple data
344 sets) and will raise a `~psycopg2.NotSupportedError` exception.
345
346
347 .. method:: setoutputsize(size [, column])
348
349 This method is exposed in compliance with the |DBAPI|. It currently
350 does nothing but it is safe to call it.
351
352
353 .. attribute:: query
354
355 Read-only attribute containing the body of the last query sent to the
356 backend (including bound arguments). ``None`` if no query has been
357 executed yet:
358
359 >>> cur.execute("INSERT INTO test (num, data) VALUES (%s, %s)", (42, 'bar'))
360 >>> cur.query
361 "INSERT INTO test (num, data) VALUES (42, E'bar')"
362
363 .. extension::
364
365 The `query` attribute is a Psycopg extension to the |DBAPI|.
366
367
368 .. attribute:: statusmessage
369
370 Read-only attribute containing the message returned by the last
371 command:
372
373 >>> cur.execute("INSERT INTO test (num, data) VALUES (%s, %s)", (42, 'bar'))
374 >>> cur.statusmessage
375 'INSERT 0 1'
376
377 .. extension::
378
379 The `statusmessage` attribute is a Psycopg extension to the
380 |DBAPI|.
381
382
383 .. attribute:: tzinfo_factory
384
385 The time zone factory used to handle data types such as
386 :sql:`TIMESTAMP WITH TIME ZONE`. It should be a |tzinfo|_ object.
387 See also the `psycopg2.tz` module.
388
389 .. |tzinfo| replace:: `!tzinfo`
390 .. _tzinfo: http://docs.python.org/library/datetime.html#tzinfo-objects
391
392
393 .. rubric:: COPY-related methods
394
395 .. extension::
396
397 The :sql:`COPY` command is a PostgreSQL extension to the SQL standard.
398 As such, its support is a Psycopg extension to the |DBAPI|.
399
400 .. method:: copy_from(file, table, sep='\\t', null='\\N', columns=None)
401
402 Read data *from* the file-like object `file` appending them to
403 the table named `table`. `file` must have both
404 `!read()` and `!readline()` method. See :ref:`copy` for an
405 overview.
406
407 The optional argument `sep` is the columns separator and
408 `null` represents :sql:`NULL` values in the file.
409
410 The `columns` argument is a sequence containing the name of the
411 fields where the read data will be entered. Its length and column
412 type should match the content of the read file. If not specifies, it
413 is assumed that the entire table matches the file structure.
414
415 >>> f = StringIO("42\tfoo\n74\tbar\n")
416 >>> cur.copy_from(f, 'test', columns=('num', 'data'))
417 >>> cur.execute("select * from test where id > 5;")
418 >>> cur.fetchall()
419 [(6, 42, 'foo'), (7, 74, 'bar')]
420
421 .. versionchanged:: 2.0.6
422 added the `columns` parameter.
423
424
425 .. method:: copy_to(file, table, sep='\\t', null='\\N', columns=None)
426
427 Write the content of the table named `table` *to* the file-like
428 object `file`. `file` must have a `!write()` method.
429 See :ref:`copy` for an overview.
430
431 The optional argument `sep` is the columns separator and
432 `null` represents :sql:`NULL` values in the file.
433
434 The `columns` argument is a sequence of field names: if not
435 ``None`` only the specified fields will be included in the dump.
436
437 >>> cur.copy_to(sys.stdout, 'test', sep="|")
438 1|100|abc'def
439 2|\N|dada
440 ...
441
442 .. versionchanged:: 2.0.6
443 added the `columns` parameter.
444
445
446 .. method:: copy_expert(sql, file [, size])
447
448 Submit a user-composed :sql:`COPY` statement. The method is useful to
449 handle all the parameters that PostgreSQL makes available (see
450 |COPY|__ command documentation).
451
452 `file` must be an open, readable file for :sql:`COPY FROM` or an
453 open, writeable file for :sql:`COPY TO`. The optional `size`
454 argument, when specified for a :sql:`COPY FROM` statement, will be
455 passed to `file`\ 's read method to control the read buffer
456 size.
457
458 >>> cur.copy_expert("COPY test TO STDOUT WITH CSV HEADER", sys.stdout)
459 id,num,data
460 1,100,abc'def
461 2,,dada
462 ...
463
464 .. |COPY| replace:: :sql:`COPY`
465 .. __: http://www.postgresql.org/docs/8.4/static/sql-copy.html
466
467 .. versionadded:: 2.0.6
468
469
470.. testcode::
471 :hide:
472
473 conn.rollback()
0474
=== added file 'doc/html/_sources/errorcodes.txt'
--- doc/html/_sources/errorcodes.txt 1970-01-01 00:00:00 +0000
+++ doc/html/_sources/errorcodes.txt 2010-07-28 20:35:51 +0000
@@ -0,0 +1,76 @@
1`psycopg2.errorcodes` -- Error codes defined by PostgreSQL
2===============================================================
3
4.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
5
6.. index::
7 single: Error; Codes
8
9.. module:: psycopg2.errorcodes
10
11.. testsetup:: *
12
13 from psycopg2 import errorcodes
14
15.. versionadded:: 2.0.6
16
17This module contains symbolic names for all PostgreSQL error codes and error
18classes codes. Subclasses of `~psycopg2.Error` make the PostgreSQL error
19code available in the `~psycopg2.Error.pgcode` attribute.
20
21From PostgreSQL documentation:
22
23 All messages emitted by the PostgreSQL server are assigned five-character
24 error codes that follow the SQL standard's conventions for :sql:`SQLSTATE`
25 codes. Applications that need to know which error condition has occurred
26 should usually test the error code, rather than looking at the textual
27 error message. The error codes are less likely to change across
28 PostgreSQL releases, and also are not subject to change due to
29 localization of error messages. Note that some, but not all, of the error
30 codes produced by PostgreSQL are defined by the SQL standard; some
31 additional error codes for conditions not defined by the standard have
32 been invented or borrowed from other databases.
33
34 According to the standard, the first two characters of an error code
35 denote a class of errors, while the last three characters indicate a
36 specific condition within that class. Thus, an application that does not
37 recognize the specific error code can still be able to infer what to do
38 from the error class.
39
40.. seealso:: `PostgreSQL Error Codes table`__
41
42 .. __: http://www.postgresql.org/docs/8.4/static/errcodes-appendix.html#ERRCODES-TABLE
43
44
45An example of the available constants defined in the module:
46
47 >>> errorcodes.CLASS_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
48 '42'
49 >>> errorcodes.UNDEFINED_TABLE
50 '42P01'
51
52Constants representing all the error values documented by PostgreSQL versions
53between 8.1 and 8.4 are included in the module.
54
55
56.. autofunction:: lookup(code)
57
58 .. doctest::
59
60 >>> try:
61 ... cur.execute("SELECT ouch FROM aargh;")
62 ... except Exception, e:
63 ... pass
64 ...
65 >>> errorcodes.lookup(e.pgcode[:2])
66 'CLASS_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION'
67 >>> errorcodes.lookup(e.pgcode)
68 'UNDEFINED_TABLE'
69
70 .. versionadded:: 2.0.14
71
72
73.. testcode::
74 :hide:
75
76 conn.rollback()
077
=== added file 'doc/html/_sources/extensions.txt'
--- doc/html/_sources/extensions.txt 1970-01-01 00:00:00 +0000
+++ doc/html/_sources/extensions.txt 2010-07-28 20:35:51 +0000
@@ -0,0 +1,565 @@
1`psycopg2.extensions` -- Extensions to the DB API
2======================================================
3
4.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
5
6.. module:: psycopg2.extensions
7
8.. testsetup:: *
9
10 from psycopg2.extensions import AsIs, Binary, QuotedString, ISOLATION_LEVEL_AUTOCOMMIT
11
12The module contains a few objects and function extending the minimum set of
13functionalities defined by the |DBAPI|_.
14
15
16.. class:: connection
17
18 Is the class usually returned by the `~psycopg2.connect()` function.
19 It is exposed by the `extensions` module in order to allow
20 subclassing to extend its behaviour: the subclass should be passed to the
21 `!connect()` function using the `connection_factory` parameter.
22 See also :ref:`subclassing-connection`.
23
24 Subclasses should have constructor signature :samp:`({dsn}, {async}=0)`.
25
26 For a complete description of the class, see `connection`.
27
28.. class:: cursor
29
30 It is the class usually returnded by the `connection.cursor()`
31 method. It is exposed by the `extensions` module in order to allow
32 subclassing to extend its behaviour: the subclass should be passed to the
33 `!cursor()` method using the `cursor_factory` parameter. See
34 also :ref:`subclassing-cursor`.
35
36 For a complete description of the class, see `cursor`.
37
38.. class:: lobject(conn [, oid [, mode [, new_oid [, new_file ]]]])
39
40 Wrapper for a PostgreSQL large object. See :ref:`large-objects` for an
41 overview.
42
43 The class can be subclassed: see the `connection.lobject()` to know
44 how to specify a `!lobject` subclass.
45
46 .. versionadded:: 2.0.8
47
48 .. attribute:: oid
49
50 Database OID of the object.
51
52 .. attribute:: mode
53
54 The mode the database was open (``r``, ``w``, ``rw`` or ``n``).
55
56 .. method:: read(bytes=-1)
57
58 Read a chunk of data from the current file position. If -1 (default)
59 read all the remaining data.
60
61 .. method:: write(str)
62
63 Write a string to the large object. Return the number of bytes
64 written.
65
66 .. method:: export(file_name)
67
68 Export the large object content to the file system.
69
70 The method uses the efficient |lo_export|_ libpq function.
71
72 .. |lo_export| replace:: `!lo_export()`
73 .. _lo_export: http://www.postgresql.org/docs/8.4/static/lo-interfaces.html#AEN36330
74
75 .. method:: seek(offset, whence=0)
76
77 Set the lobject current position.
78
79 .. method:: tell()
80
81 Return the lobject current position.
82
83 .. method:: truncate(len=0)
84
85 .. versionadded:: 2.2.0
86
87 Truncate the lobject to the given size.
88
89 The method will only be available if Psycopg has been built against libpq
90 from PostgreSQL 8.3 or later and can only be used with PostgreSQL servers
91 running these versions. It uses the |lo_truncate|_ libpq function.
92
93 .. |lo_truncate| replace:: `!lo_truncate()`
94 .. _lo_truncate: http://www.postgresql.org/docs/8.4/static/lo-interfaces.html#AEN36420
95
96 .. method:: close()
97
98 Close the object.
99
100 .. attribute:: closed
101
102 Boolean attribute specifying if the object is closed.
103
104 .. method:: unlink()
105
106 Close the object and remove it from the database.
107
108
109.. autofunction:: set_wait_callback(f)
110
111 .. versionadded:: 2.2.0
112
113.. autofunction:: get_wait_callback()
114
115 .. versionadded:: 2.2.0
116
117
118.. _sql-adaptation-objects:
119
120SQL adaptation protocol objects
121-------------------------------
122
123Psycopg provides a flexible system to adapt Python objects to the SQL syntax
124(inspired to the :pep:`246`), allowing serialization in PostgreSQL. See
125:ref:`adapting-new-types` for a detailed description. The following objects
126deal with Python objects adaptation:
127
128.. function:: adapt(obj)
129
130 Return the SQL representation of *obj* as a string. Raise a
131 `~psycopg2.ProgrammingError` if how to adapt the object is unknown.
132 In order to allow new objects to be adapted, register a new adapter for it
133 using the `register_adapter()` function.
134
135 The function is the entry point of the adaptation mechanism: it can be
136 used to write adapters for complex objects by recursively calling
137 `!adapt()` on its components.
138
139.. function:: register_adapter(class, adapter)
140
141 Register a new adapter for the objects of class *class*.
142
143 *adapter* should be a function taking a single argument (the object
144 to adapt) and returning an object conforming the `ISQLQuote`
145 protocol (e.g. exposing a `!getquoted()` method). The `AsIs` is
146 often useful for this task.
147
148 Once an object is registered, it can be safely used in SQL queries and by
149 the `adapt()` function.
150
151.. class:: ISQLQuote(wrapped_object)
152
153 Represents the SQL adaptation protocol. Objects conforming this protocol
154 should implement a `!getquoted()` method.
155
156 Adapters may subclass `!ISQLQuote`, but is not necessary: it is
157 enough to expose a `!getquoted()` method to be conforming.
158
159 .. attribute:: _wrapped
160
161 The wrapped object passes to the constructor
162
163 .. method:: getquoted()
164
165 Subclasses or other conforming objects should return a valid SQL
166 string representing the wrapped object. The `!ISQLQuote`
167 implementation does nothing.
168
169.. class:: AsIs
170
171 Adapter conform to the `ISQLQuote` protocol useful for objects
172 whose string representation is already valid as SQL representation.
173
174 .. method:: getquoted()
175
176 Return the `str()` conversion of the wrapped object.
177
178 >>> AsIs(42).getquoted()
179 '42'
180
181.. class:: QuotedString
182
183 Adapter conform to the `ISQLQuote` protocol for string-like
184 objects.
185
186 .. method:: getquoted()
187
188 Return the string enclosed in single quotes. Any single quote
189 appearing in the the string is escaped by doubling it according to SQL
190 string constants syntax. Backslashes are escaped too.
191
192 >>> QuotedString(r"O'Reilly").getquoted()
193 "'O''Reilly'"
194
195.. class:: Binary
196
197 Adapter conform to the `ISQLQuote` protocol for binary objects.
198
199 .. method:: getquoted()
200
201 Return the string enclosed in single quotes. It performs the same
202 escaping of the `QuotedString` adapter, plus it knows how to
203 escape non-printable chars.
204
205 >>> Binary("\x00\x08\x0F").getquoted()
206 "'\\\\000\\\\010\\\\017'"
207
208 .. versionchanged:: 2.0.14
209 previously the adapter was not exposed by the `extensions`
210 module. In older versions it can be imported from the implementation
211 module `!psycopg2._psycopg`.
212
213
214
215.. class:: Boolean
216 Float
217 SQL_IN
218
219 Specialized adapters for builtin objects.
220
221.. class:: DateFromPy
222 TimeFromPy
223 TimestampFromPy
224 IntervalFromPy
225
226 Specialized adapters for Python datetime objects.
227
228.. class:: DateFromMx
229 TimeFromMx
230 TimestampFromMx
231 IntervalFromMx
232
233 Specialized adapters for `mx.DateTime`_ objects.
234
235.. data:: adapters
236
237 Dictionary of the currently registered object adapters. Use
238 `register_adapter()` to add an adapter for a new type.
239
240
241
242Database types casting functions
243--------------------------------
244
245These functions are used to manipulate type casters to convert from PostgreSQL
246types to Python objects. See :ref:`type-casting-from-sql-to-python` for
247details.
248
249.. function:: new_type(oids, name, adapter)
250
251 Create a new type caster to convert from a PostgreSQL type to a Python
252 object. The created object must be registered using
253 `register_type()` to be used.
254
255 :param oids: tuple of OIDs of the PostgreSQL type to convert.
256 :param name: the name of the new type adapter.
257 :param adapter: the adaptation function.
258
259 The object OID can be read from the `cursor.description` attribute
260 or by querying from the PostgreSQL catalog.
261
262 *adapter* should have signature :samp:`fun({value}, {cur})` where
263 *value* is the string representation returned by PostgreSQL and
264 *cur* is the cursor from which data are read. In case of
265 :sql:`NULL`, *value* will be ``None``. The adapter should return the
266 converted object.
267
268 See :ref:`type-casting-from-sql-to-python` for an usage example.
269
270
271.. function:: register_type(obj [, scope])
272
273 Register a type caster created using `new_type()`.
274
275 If *scope* is specified, it should be a `connection` or a
276 `cursor`: the type caster will be effective only limited to the
277 specified object. Otherwise it will be globally registered.
278
279
280.. data:: string_types
281
282 The global register of type casters.
283
284
285.. index::
286 single: Encoding; Mapping
287
288.. data:: encodings
289
290 Mapping from `PostgreSQL encoding`__ names to `Python codec`__ names.
291 Used by Psycopg when adapting or casting unicode strings. See
292 :ref:`unicode-handling`.
293
294 .. __: http://www.postgresql.org/docs/8.4/static/multibyte.html
295 .. __: http://docs.python.org/library/codecs.html#standard-encodings
296
297
298
299.. index::
300 single: Exceptions; Additional
301
302Additional exceptions
303---------------------
304
305The module exports a few exceptions in addition to the :ref:`standard ones
306<dbapi-exceptions>` defined by the |DBAPI|_.
307
308.. exception:: QueryCanceledError
309
310 (subclasses `~psycopg2.OperationalError`)
311
312 Error related to SQL query cancelation. It can be trapped specifically to
313 detect a timeout.
314
315 .. versionadded:: 2.0.7
316
317
318.. exception:: TransactionRollbackError
319
320 (subclasses `~psycopg2.OperationalError`)
321
322 Error causing transaction rollback (deadlocks, serialisation failures,
323 etc). It can be trapped specifically to detect a deadlock.
324
325 .. versionadded:: 2.0.7
326
327
328
329.. index::
330 pair: Isolation level; Constants
331
332.. _isolation-level-constants:
333
334Isolation level constants
335-------------------------
336
337Psycopg2 `connection` objects hold informations about the PostgreSQL
338`transaction isolation level`_. The current transaction level can be read
339from the `~connection.isolation_level` attribute. The default isolation
340level is :sql:`READ COMMITTED`. A different isolation level con be set
341through the `~connection.set_isolation_level()` method. The level can be
342set to one of the following constants:
343
344.. data:: ISOLATION_LEVEL_AUTOCOMMIT
345
346 No transaction is started when command are issued and no
347 `~connection.commit()` or `~connection.rollback()` is required.
348 Some PostgreSQL command such as :sql:`CREATE DATABASE` or :sql:`VACUUM`
349 can't run into a transaction: to run such command use::
350
351 >>> conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
352
353 See also :ref:`transactions-control`.
354
355.. data:: ISOLATION_LEVEL_READ_UNCOMMITTED
356
357 The :sql:`READ UNCOMMITTED` isolation level is defined in the SQL standard
358 but not available in the |MVCC| model of PostgreSQL: it is replaced by the
359 stricter :sql:`READ COMMITTED`.
360
361.. data:: ISOLATION_LEVEL_READ_COMMITTED
362
363 This is the default value. A new transaction is started at the first
364 `~cursor.execute()` command on a cursor and at each new
365 `!execute()` after a `~connection.commit()` or a
366 `~connection.rollback()`. The transaction runs in the PostgreSQL
367 :sql:`READ COMMITTED` isolation level.
368
369.. data:: ISOLATION_LEVEL_REPEATABLE_READ
370
371 The :sql:`REPEATABLE READ` isolation level is defined in the SQL standard
372 but not available in the |MVCC| model of PostgreSQL: it is replaced by the
373 stricter :sql:`SERIALIZABLE`.
374
375.. data:: ISOLATION_LEVEL_SERIALIZABLE
376
377 Transactions are run at a :sql:`SERIALIZABLE` isolation level. This is the
378 strictest transactions isolation level, equivalent to having the
379 transactions executed serially rather than concurrently. However
380 applications using this level must be prepared to retry reansactions due
381 to serialization failures. See `serializable isolation level`_ in
382 PostgreSQL documentation.
383
384
385
386.. index::
387 pair: Transaction status; Constants
388
389.. _transaction-status-constants:
390
391Transaction status constants
392----------------------------
393
394These values represent the possible status of a transaction: the current value
395can be read using the `connection.get_transaction_status()` method.
396
397.. data:: TRANSACTION_STATUS_IDLE
398
399 The session is idle and there is no current transaction.
400
401.. data:: TRANSACTION_STATUS_ACTIVE
402
403 A command is currently in progress.
404
405.. data:: TRANSACTION_STATUS_INTRANS
406
407 The session is idle in a valid transaction block.
408
409.. data:: TRANSACTION_STATUS_INERROR
410
411 The session is idle in a failed transaction block.
412
413.. data:: TRANSACTION_STATUS_UNKNOWN
414
415 Reported if the connection with the server is bad.
416
417
418
419.. index::
420 pair: Connection status; Constants
421
422.. _connection-status-constants:
423
424Connection status constants
425---------------------------
426
427These values represent the possible status of a connection: the current value
428can be read from the `~connection.status` attribute.
429
430It is possible to find the connection in other status than the one shown below.
431Those are the only states in which a working connection is expected to be found
432during the execution of regular Python client code: other states are for
433internal usage and Python code should not rely on them.
434
435.. data:: STATUS_READY
436
437 Connection established. No transaction in progress.
438
439.. data:: STATUS_BEGIN
440
441 Connection established. A transaction is currently in progress.
442
443.. data:: STATUS_IN_TRANSACTION
444
445 An alias for `STATUS_BEGIN`
446
447
448
449.. index::
450 pair: Poll status; Constants
451
452.. _poll-constants:
453
454Poll constants
455--------------
456
457.. versionadded:: 2.2.0
458
459These values can be returned by `connection.poll()` during asynchronous
460connection and communication. They match the values in the libpq enum
461`!PostgresPollingStatusType`. See :ref:`async-support` and
462:ref:`green-support`.
463
464.. data:: POLL_OK
465
466 The data being read is available, or the file descriptor is ready for
467 writing: reading or writing will not block.
468
469.. data:: POLL_READ
470
471 Some data is being read from the backend, but it is not available yet on
472 the client and reading would block. Upon receiving this value, the client
473 should wait for the connection file descriptor to be ready *for reading*.
474 For example::
475
476 select.select([conn.fileno()], [], [])
477
478.. data:: POLL_WRITE
479
480 Some data is being sent to the backend but the connection file descriptor
481 can't currently accept new data. Upon receiving this value, the client
482 should wait for the connection file descriptor to be ready *for writing*.
483 For example::
484
485 select.select([], [conn.fileno()], [])
486
487.. data:: POLL_ERROR
488
489 There was a problem during connection polling. This value should actually
490 never be returned: in case of poll error usually an exception containing
491 the relevant details is raised.
492
493
494
495Additional database types
496-------------------------
497
498The `!extensions` module includes typecasters for many standard
499PostgreSQL types. These objects allow the conversion of returned data into
500Python objects. All the typecasters are automatically registered, except
501`UNICODE` and `UNICODEARRAY`: you can register them using
502`register_type()` in order to receive Unicode objects instead of strings
503from the database. See :ref:`unicode-handling` for details.
504
505.. data:: BOOLEAN
506 DATE
507 DECIMAL
508 FLOAT
509 INTEGER
510 INTERVAL
511 LONGINTEGER
512 TIME
513 UNICODE
514
515 Typecasters for basic types. Notice that a few other ones (`~psycopg2.BINARY`,
516 `~psycopg2.DATETIME`, `~psycopg2.NUMBER`, `~psycopg2.ROWID`,
517 `~psycopg2.STRING`) are exposed by the `psycopg2` module for |DBAPI|_
518 compliance.
519
520.. data:: BINARYARRAY
521 BOOLEANARRAY
522 DATEARRAY
523 DATETIMEARRAY
524 DECIMALARRAY
525 FLOATARRAY
526 INTEGERARRAY
527 INTERVALARRAY
528 LONGINTEGERARRAY
529 ROWIDARRAY
530 STRINGARRAY
531 TIMEARRAY
532 UNICODEARRAY
533
534 Typecasters to convert arrays of sql types into Python lists.
535
536.. data:: PYDATE
537 PYDATETIME
538 PYINTERVAL
539 PYTIME
540 PYDATEARRAY
541 PYDATETIMEARRAY
542 PYINTERVALARRAY
543 PYTIMEARRAY
544
545 Typecasters to convert time-related data types to Python `!datetime`
546 objects.
547
548.. data:: MXDATE
549 MXDATETIME
550 MXINTERVAL
551 MXTIME
552 MXDATEARRAY
553 MXDATETIMEARRAY
554 MXINTERVALARRAY
555 MXTIMEARRAY
556
557 Typecasters to convert time-related data types to `mx.DateTime`_ objects.
558 Only available if Psycopg was compiled with `!mx` support.
559
560.. versionchanged:: 2.2.0
561 previously the `DECIMAL` typecaster and the specific time-related
562 typecasters (`!PY*` and `!MX*`) were not exposed by the `extensions`
563 module. In older versions they can be imported from the implementation
564 module `!psycopg2._psycopg`.
565
0566
=== added file 'doc/html/_sources/extras.txt'
--- doc/html/_sources/extras.txt 1970-01-01 00:00:00 +0000
+++ doc/html/_sources/extras.txt 2010-07-28 20:35:51 +0000
@@ -0,0 +1,165 @@
1`psycopg2.extras` -- Miscellaneous goodies for Psycopg 2
2=============================================================
3
4.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
5
6.. module:: psycopg2.extras
7
8.. testsetup::
9
10 import psycopg2.extras
11 from psycopg2.extras import Inet
12
13 create_test_table()
14
15This module is a generic place used to hold little helper functions and
16classes until a better place in the distribution is found.
17
18
19.. index::
20 pair: Cursor; Dictionary
21
22.. _dict-cursor:
23
24Dictionary-like cursor
25----------------------
26
27The dict cursors allow to access to the retrieved records using an iterface
28similar to the Python dictionaries instead of the tuples. You can use it
29either passing `DictConnection` as `connection_factory` argument
30to the `~psycopg2.connect()` function or passing `DictCursor` as
31the `!cursor_factory` argument to the `~connection.cursor()` method
32of a regular `connection`.
33
34 >>> dict_cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
35 >>> dict_cur.execute("INSERT INTO test (num, data) VALUES(%s, %s)",
36 ... (100, "abc'def"))
37 >>> dict_cur.execute("SELECT * FROM test")
38 >>> rec = dict_cur.fetchone()
39 >>> rec['id']
40 1
41 >>> rec['num']
42 100
43 >>> rec['data']
44 "abc'def"
45
46The records still support indexing as the original tuple:
47
48 >>> rec[2]
49 "abc'def"
50
51
52.. autoclass:: DictCursor
53
54.. autoclass:: DictConnection
55
56.. autoclass:: DictRow
57
58
59Real dictionary cursor
60^^^^^^^^^^^^^^^^^^^^^^
61
62.. autoclass:: RealDictCursor
63
64.. autoclass:: RealDictConnection
65
66.. autoclass:: RealDictRow
67
68
69
70.. index::
71 pair: Cursor; Logging
72
73Logging cursor
74--------------
75
76.. autoclass:: LoggingConnection
77 :members: initialize,filter
78
79.. autoclass:: LoggingCursor
80
81
82.. autoclass:: MinTimeLoggingConnection
83 :members: initialize,filter
84
85.. autoclass:: MinTimeLoggingCursor
86
87
88
89.. index::
90 pair: UUID; Data types
91
92UUID data type
93--------------
94
95.. versionadded:: 2.0.9
96.. versionchanged:: 2.0.13 added UUID array support.
97
98.. doctest::
99
100 >>> psycopg2.extras.register_uuid()
101 <psycopg2._psycopg.type object at 0x...>
102
103 >>> # Python UUID can be used in SQL queries
104 >>> import uuid
105 >>> my_uuid = uuid.UUID('{12345678-1234-5678-1234-567812345678}')
106 >>> psycopg2.extensions.adapt(my_uuid).getquoted()
107 "'12345678-1234-5678-1234-567812345678'::uuid"
108
109 >>> # PostgreSQL UUID are transformed into Python UUID objects.
110 >>> cur.execute("SELECT 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid")
111 >>> cur.fetchone()[0]
112 UUID('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11')
113
114
115.. autofunction:: register_uuid
116
117.. autoclass:: UUID_adapter
118
119
120
121.. index::
122 pair: INET; Data types
123
124:sql:`inet` data type
125----------------------
126
127.. versionadded:: 2.0.9
128
129.. doctest::
130
131 >>> psycopg2.extras.register_inet()
132 <psycopg2._psycopg.type object at 0x...>
133
134 >>> cur.mogrify("SELECT %s", (Inet('127.0.0.1/32'),))
135 "SELECT E'127.0.0.1/32'::inet"
136
137 >>> cur.execute("SELECT '192.168.0.1/24'::inet")
138 >>> cur.fetchone()[0].addr
139 '192.168.0.1/24'
140
141
142.. autofunction:: register_inet()
143
144.. autoclass:: Inet
145
146
147
148.. index::
149 single: Time zones; Fractional
150
151Fractional time zones
152---------------------
153
154.. autofunction:: register_tstz_w_secs
155
156 .. versionadded:: 2.0.9
157
158.. index::
159 pair: Example; Coroutine;
160
161Coroutine support
162-----------------
163
164.. autofunction:: wait_select(conn)
165
0166
=== added file 'doc/html/_sources/faq.txt'
--- doc/html/_sources/faq.txt 1970-01-01 00:00:00 +0000
+++ doc/html/_sources/faq.txt 2010-07-28 20:35:51 +0000
@@ -0,0 +1,139 @@
1Frequently Asked Questions
2==========================
3
4.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com>
5
6Here are a few gotchas you may encounter using `psycopg2`. Feel free to
7suggest new entries!
8
9
10Problems with transactions handling
11-----------------------------------
12
13.. cssclass:: faq
14
15Why does `!psycopg2` leave database sessions "idle in transaction"?
16 Psycopg normally starts a new transaction the first time a query is
17 executed, e.g. calling `cursor.execute()`, even if the command is a
18 :sql:`SELECT`. The transaction is not closed until an explicit
19 `~connection.commit()` or `~connection.rollback()`.
20
21 If you are writing a long-living program, you should probably ensure to
22 call one of the transaction closing methods before leaving the connection
23 unused for a long time (which may also be a few seconds, depending on the
24 concurrency level in your database). Alternatively you can use a
25 connection in :ref:`autocommit <autocommit>` mode to avoid a new
26 transaction to be started at the first command.
27
28I receive the error *current transaction is aborted, commands ignored until end of transaction block* and can't do anything else!
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: