Merge lp:~groldster/ubuntu/maverick/psycopg2/merge-611040 into lp:ubuntu/maverick/psycopg2
- Maverick (10.10)
- merge-611040
- Merge into maverick
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
Review via email: mp+31203@code.launchpad.net |
Commit message
Description of the change
merge psycopg2 2.2.1-1 (main) from Debian unstable (main)
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2009-10-12 06:50:00 +0000 |
3 | +++ ChangeLog 2010-07-28 20:35:51 +0000 |
4 | @@ -1,3 +1,134 @@ |
5 | +2010-05-17 Federico Di Gregorio <fog@initd.org> |
6 | + |
7 | + * Release 2.2.1. |
8 | + |
9 | + * Builds again on Windows. |
10 | + |
11 | +2010-05-16 Federico Di Gregorio <fog@initd.org> |
12 | + |
13 | + * Release 2.2.0. |
14 | + |
15 | +2010-05-15 Federico Di Gregorio <fog@initd.org> |
16 | + |
17 | + * typecast.c: Fixed problem related to receiving None from Python |
18 | + when a string was expected. |
19 | + |
20 | +2010-05-07 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
21 | + |
22 | + * psycopg/adapter_datetime.c: Fixed TimestampFromTicks for second |
23 | + values > 59.5. |
24 | + |
25 | + Bug reported and fixed by Jozsef Szalay on 2010-05-06 at 14:11:59.999920. |
26 | + |
27 | + * psycopg/adapter_datetime.c: Fixed same bug for TimeFromTicks. |
28 | + |
29 | +2010-05-04 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
30 | + |
31 | + * Added typecasters for arrays of specific MX/Py time-related types. |
32 | + |
33 | + * psycopg/adapter_[mx]datetime.c: Explicit cast of the SQL representation |
34 | + of time-related objects. |
35 | + |
36 | +2010-05-03 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
37 | + |
38 | + * psycopg/adapter_binary.c: Adapt buffer objects using an explicit cast on |
39 | + the string literal (bug reported by Peter Eisentraut) |
40 | + |
41 | +2010-04-20 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
42 | + |
43 | + * lib/pqpath.c: Fixed reference leak in notify reception. |
44 | + |
45 | + * Notifies are collected if available after every query execution. |
46 | + |
47 | +2010-04-13 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
48 | + |
49 | + * lib/extensions.py: DECIMAL typecaster imported from _psycopg. |
50 | + |
51 | + * lib/extensions.py: PY* and MX* time typecaster imported from _psycopg. |
52 | + |
53 | +2010-04-11 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
54 | + |
55 | + * psycopg/connection_type.c: Correctly parse keywords in connect(). |
56 | + |
57 | +2010-04-07 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
58 | + |
59 | + * psycopg/pqpath.c: Ensure running COPY in blocking mode. |
60 | + |
61 | + * psycopg/pqpath.c: Free the GIL in blocking operations in V2 COPY FROM. |
62 | + |
63 | + * psycopg/pqpath.c: Evaluate Python objects only once outside the COPY I/O |
64 | + loops. |
65 | + |
66 | +2010-04-05 Federico Di Gregorio <fog@initd.org> |
67 | + |
68 | + * Fixed problem with asynchronous NOTIFYs. |
69 | + |
70 | + * Integrated async pacthes from Jan's git tree. |
71 | + |
72 | +2010-03-13 Federico Di Gregorio <fog@initd.org> |
73 | + |
74 | + * Release 2.0.14. |
75 | + |
76 | +2010-03-11 Federico Di Gregorio <fog@initd.org> |
77 | + |
78 | + * setup.py: one-liner from Devrim GÜNDÜZ to build with PostgreSQL |
79 | + alpha. |
80 | + |
81 | +2010-02-28 Federico Di Gregorio <fog@initd.org> |
82 | + |
83 | + * psycopg/adapt_decimal.c: Python 2.4 decimal type does not support |
84 | + .isfinite() and two different calls to ._isinfinity() and ._isnan() are |
85 | + required. This fixes both a test failure and a segfault. |
86 | + |
87 | +2010-02-15 Federico Di Gregorio <fog@initd.org> |
88 | + |
89 | + * Added new Decimal adapter that correctly converts NaN and infinity |
90 | + to PostgreSQL NaN numeric values. Also added tests. |
91 | + |
92 | +2010-02-15 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
93 | + |
94 | + * lib/errorcodes.py: Updated to PostgreSQL 8.4; added lookup() function. |
95 | + |
96 | +2010-02-12 Daniele Varrazzo <daniele.varrazzo@gmail.com> |
97 | + |
98 | + * Stop the loop variable used to create __all__ leaking in the module. |
99 | + |
100 | + * Fixed Inet constructor. |
101 | + |
102 | + * Fixed docstring for 'QueryCanceledError' exception. |
103 | + |
104 | +2010-02-10 Federico Di Gregorio <fog@initd.org> |
105 | + |
106 | + * lib/extensions.py: Binary was not imported from _psycopg; now it is |
107 | + |
108 | + * lib/__init__: SQL_IN adapter is now automatically registered. |
109 | + |
110 | + * ZPsycopgDA/db.py: removed logging debug calls; psycopg does |
111 | + not depend on the logger module. |
112 | + |
113 | +2010-02-12 Federico Di Gregorio <fog@initd.org> |
114 | + |
115 | + * License migration: psycopg2 is now LGPL3 + OpenSSL exception. |
116 | + |
117 | + * TODO file was never updated so lets remove it. |
118 | + |
119 | +2010-02-10 Federico Di Gregorio <fog@initd.org> |
120 | + |
121 | + * lib/extras.py: fixed register_tstz_w_secs() error as reported by |
122 | + Karsten Hilbert. |
123 | + |
124 | +2009-11-25 Federico Di Gregorio <fog@initd.org> |
125 | + |
126 | + * psycopg/microprotocols.c: "can't adapt" message now includes full |
127 | + type information (adapted patch from Eric Chamberlain). |
128 | + |
129 | + * tests/types_basic.py: fixed test broken by float precision fix. |
130 | + |
131 | +2009-11-09 Federico Di Gregorio <fog@initd.org> |
132 | + |
133 | + * psycopg/adapter_pfloat.c: applied patch from Remy Blankto fix float |
134 | + loss of precision. |
135 | + |
136 | 2009-10-04 Federico Di Gregorio <fog@initd.org> |
137 | |
138 | * Release 2.0.13. |
139 | |
140 | === modified file 'LICENSE' |
141 | --- LICENSE 2006-08-09 10:28:30 +0000 |
142 | +++ LICENSE 2010-07-28 20:35:51 +0000 |
143 | @@ -1,24 +1,32 @@ |
144 | -psycopg and the GPL |
145 | -=================== |
146 | - |
147 | -psycopg is free software; you can redistribute it and/or modify |
148 | -it under the terms of the GNU General Public License as published by |
149 | -the Free Software Foundation; either version 2 of the License, or |
150 | -(at your option) any later version. See file COPYING for details. |
151 | - |
152 | -As a special exception, specific permission is granted for the GPLed |
153 | -code in this distribition to be linked to OpenSSL and PostgreSQL libpq |
154 | -without invoking GPL clause 2(b). |
155 | - |
156 | -Note that the GPL was chosen to avoid proprietary adapters based on |
157 | -psycopg code. Using psycopg in a proprietary product (even bundling |
158 | -psycopg with the proprietary product) is fine as long as: |
159 | - |
160 | - 1. psycopg is called from Python only using only the provided API |
161 | - (i.e., no linking with C code and no C modules based on it); and |
162 | - |
163 | - 2. all the other points of the GPL are respected (you offer a copy |
164 | - of psycopg's source code, and so on.) |
165 | +psycopg2 and the LGPL |
166 | +===================== |
167 | + |
168 | +psycopg2 is free software: you can redistribute it and/or modify it |
169 | +under the terms of the GNU Lesser General Public License as published |
170 | +by the Free Software Foundation, either version 3 of the License, or |
171 | +(at your option) any later version. |
172 | + |
173 | +psycopg2 is distributed in the hope that it will be useful, but WITHOUT |
174 | +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
175 | +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
176 | +License for more details. |
177 | + |
178 | +In addition, as a special exception, the copyright holders give |
179 | +permission to link this program with the OpenSSL library (or with |
180 | +modified versions of OpenSSL that use the same license as OpenSSL), |
181 | +and distribute linked combinations including the two. |
182 | + |
183 | +You must obey the GNU Lesser General Public License in all respects for |
184 | +all of the code used other than OpenSSL. If you modify file(s) with this |
185 | +exception, you may extend this exception to your version of the file(s), |
186 | +but you are not obligated to do so. If you do not wish to do so, delete |
187 | +this exception statement from your version. If you delete this exception |
188 | +statement from all source files in the program, then also delete it here. |
189 | + |
190 | +You should have received a copy of the GNU Lesser General Public License |
191 | +along with psycopg2 (see the doc/ directory.) |
192 | +If not, see <http://www.gnu.org/licenses/>. |
193 | + |
194 | |
195 | Alternative licenses |
196 | ==================== |
197 | @@ -44,17 +52,3 @@ |
198 | be misrepresented as being the original software. |
199 | |
200 | 3. This notice may not be removed or altered from any source distribution. |
201 | - |
202 | -psycopg is distributed in the hope that it will be useful, |
203 | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
204 | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
205 | -GNU General Public License for more details. |
206 | - |
207 | -Proprietary licenses |
208 | -==================== |
209 | - |
210 | -A non-exclusive license is available for companies that want to include |
211 | -psycopg in their proprietary products without respecting the spirit of the |
212 | -GPL. The price of the license is one day of development done by the author, |
213 | -at the consulting fee he applies to his usual customers at the day of the |
214 | -request. |
215 | |
216 | === modified file 'MANIFEST' |
217 | --- MANIFEST 2009-10-12 06:50:00 +0000 |
218 | +++ MANIFEST 2010-07-28 20:35:51 +0000 |
219 | @@ -4,6 +4,8 @@ |
220 | LICENSE |
221 | MANIFEST |
222 | MANIFEST.in |
223 | +NEWS-2.0 |
224 | +NEWS-2.2 |
225 | README |
226 | setup.cfg |
227 | setup.py |
228 | @@ -37,13 +39,73 @@ |
229 | debian/rules |
230 | debian/watch |
231 | debian/zope-psycopgda2.dzproduct |
232 | +doc/COPYING |
233 | +doc/COPYING.LESSER |
234 | doc/ChangeLog-1.x |
235 | doc/HACKING |
236 | +doc/Makefile |
237 | +doc/README |
238 | doc/SUCCESS |
239 | -doc/TODO |
240 | -doc/api-screen.css |
241 | -doc/async.txt |
242 | -doc/extensions.rst |
243 | +doc/pep-0249.txt |
244 | +doc/psycopg2.txt |
245 | +doc/html/.buildinfo |
246 | +doc/html/advanced.html |
247 | +doc/html/connection.html |
248 | +doc/html/cursor.html |
249 | +doc/html/errorcodes.html |
250 | +doc/html/extensions.html |
251 | +doc/html/extras.html |
252 | +doc/html/faq.html |
253 | +doc/html/genindex.html |
254 | +doc/html/index.html |
255 | +doc/html/modindex.html |
256 | +doc/html/module.html |
257 | +doc/html/objects.inv |
258 | +doc/html/pool.html |
259 | +doc/html/search.html |
260 | +doc/html/searchindex.js |
261 | +doc/html/tz.html |
262 | +doc/html/usage.html |
263 | +doc/html/_sources/advanced.txt |
264 | +doc/html/_sources/connection.txt |
265 | +doc/html/_sources/cursor.txt |
266 | +doc/html/_sources/errorcodes.txt |
267 | +doc/html/_sources/extensions.txt |
268 | +doc/html/_sources/extras.txt |
269 | +doc/html/_sources/faq.txt |
270 | +doc/html/_sources/index.txt |
271 | +doc/html/_sources/module.txt |
272 | +doc/html/_sources/pool.txt |
273 | +doc/html/_sources/tz.txt |
274 | +doc/html/_sources/usage.txt |
275 | +doc/html/_static/basic.css |
276 | +doc/html/_static/default.css |
277 | +doc/html/_static/doctools.js |
278 | +doc/html/_static/file.png |
279 | +doc/html/_static/jquery.js |
280 | +doc/html/_static/minus.png |
281 | +doc/html/_static/plus.png |
282 | +doc/html/_static/psycopg.css |
283 | +doc/html/_static/pygments.css |
284 | +doc/html/_static/searchtools.js |
285 | +doc/src/Makefile |
286 | +doc/src/advanced.rst |
287 | +doc/src/conf.py |
288 | +doc/src/connection.rst |
289 | +doc/src/cursor.rst |
290 | +doc/src/errorcodes.rst |
291 | +doc/src/extensions.rst |
292 | +doc/src/extras.rst |
293 | +doc/src/faq.rst |
294 | +doc/src/index.rst |
295 | +doc/src/module.rst |
296 | +doc/src/pool.rst |
297 | +doc/src/tz.rst |
298 | +doc/src/usage.rst |
299 | +doc/src/_static/psycopg.css |
300 | +doc/src/tools/stitch_text.py |
301 | +doc/src/tools/lib/dbapi_extension.py |
302 | +doc/src/tools/lib/sql_role.py |
303 | examples/binary.py |
304 | examples/copy_from.py |
305 | examples/copy_to.py |
306 | @@ -84,6 +146,8 @@ |
307 | psycopg/adapter_mxdatetime.h |
308 | psycopg/adapter_pboolean.c |
309 | psycopg/adapter_pboolean.h |
310 | +psycopg/adapter_pdecimal.c |
311 | +psycopg/adapter_pdecimal.h |
312 | psycopg/adapter_pfloat.c |
313 | psycopg/adapter_pfloat.h |
314 | psycopg/adapter_qstring.c |
315 | @@ -95,6 +159,8 @@ |
316 | psycopg/cursor.h |
317 | psycopg/cursor_int.c |
318 | psycopg/cursor_type.c |
319 | +psycopg/green.c |
320 | +psycopg/green.h |
321 | psycopg/lobject.h |
322 | psycopg/lobject_int.c |
323 | psycopg/lobject_type.c |
324 | @@ -129,16 +195,20 @@ |
325 | psycopg2da/psycopg2da-configure.zcml |
326 | psycopg2da/tests.py |
327 | scripts/buildtypes.py |
328 | -scripts/ext2html.py |
329 | -scripts/makedocs.py |
330 | +scripts/make_errorcodes.py |
331 | scripts/maketypes.sh |
332 | tests/__init__.py |
333 | tests/bugX000.py |
334 | +tests/bug_gc.py |
335 | tests/dbapi20.py |
336 | tests/extras_dictcursor.py |
337 | +tests/test_async.py |
338 | tests/test_connection.py |
339 | +tests/test_copy.py |
340 | tests/test_dates.py |
341 | +tests/test_green.py |
342 | tests/test_lobject.py |
343 | +tests/test_notify.py |
344 | tests/test_psycopg2_dbapi20.py |
345 | tests/test_quote.py |
346 | tests/test_transaction.py |
347 | |
348 | === modified file 'MANIFEST.in' |
349 | --- MANIFEST.in 2007-06-18 22:44:12 +0000 |
350 | +++ MANIFEST.in 2010-07-28 20:35:51 +0000 |
351 | @@ -5,9 +5,12 @@ |
352 | recursive-include psycopg2da * |
353 | recursive-include examples *.py somehackers.jpg whereareyou.jpg |
354 | recursive-include debian * |
355 | -recursive-include doc TODO HACKING SUCCESS ChangeLog-1.x async.txt |
356 | -recursive-include doc *.rst *.css *.html |
357 | +recursive-include doc README TODO HACKING SUCCESS COPYING* ChangeLog-1.x pep-0249.txt |
358 | +recursive-include doc *.txt *.html *.css *.js Makefile |
359 | +recursive-include doc/src *.rst *.py *.css Makefile |
360 | +recursive-include doc/html * |
361 | +prune doc/src/_build |
362 | recursive-include scripts *.py *.sh |
363 | include scripts/maketypes.sh scripts/buildtypes.py |
364 | -include AUTHORS README INSTALL LICENSE ChangeLog |
365 | +include AUTHORS README INSTALL LICENSE NEWS-2.0 NEWS-2.2 ChangeLog |
366 | include PKG-INFO MANIFEST.in MANIFEST setup.py setup.cfg |
367 | |
368 | === added file 'NEWS-2.0' |
369 | --- NEWS-2.0 1970-01-01 00:00:00 +0000 |
370 | +++ NEWS-2.0 2010-07-28 20:35:51 +0000 |
371 | @@ -0,0 +1,586 @@ |
372 | +What's new in psycopg 2.0.14 |
373 | +---------------------------- |
374 | + |
375 | +* New features: |
376 | + - Support for adapting tuples to PostgreSQL arrays is now enabled by |
377 | + default and does not require importing psycopg2.extensions anymore. |
378 | + - "can't adapt" error message now includes full type information. |
379 | + - Thank to Daniele Varrazzo (piro) psycopg2's source package now includes |
380 | + full documentation in HTML and plain text format. |
381 | + |
382 | +* Bug fixes: |
383 | + - No loss of precision when using floats anymore. |
384 | + - decimal.Decimal "nan" and "infinity" correctly converted to PostgreSQL |
385 | + numeric NaN values (note that PostgreSQL numeric type does not support |
386 | + infinity but just NaNs.) |
387 | + - psycopg2.extensions now includes Binary. |
388 | + |
389 | +* It seems we're good citizens of the free software ecosystem and that big |
390 | + big big companies and people ranting on the pgsql-hackers mailing list |
391 | + we'll now not dislike us. *g* (See LICENSE file for the details.) |
392 | + |
393 | + |
394 | +What's new in psycopg 2.0.13 |
395 | +---------------------------- |
396 | + |
397 | +* New features: |
398 | + - Support for UUID arrays. |
399 | + - It is now possible to build psycopg linking to a static libpq |
400 | + library. |
401 | + |
402 | +* Bug fixes: |
403 | + - Fixed a deadlock related to using the same connection with |
404 | + multiple cursors from different threads. |
405 | + - Builds again with MSVC. |
406 | + |
407 | + |
408 | +What's new in psycopg 2.0.12 |
409 | +---------------------------- |
410 | + |
411 | +* New features: |
412 | + - The connection object now has a reset() method that can be used to |
413 | + reset the connection to its default state. |
414 | + |
415 | +* Bug fixes: |
416 | + - copy_to() and copy_from() now accept a much larger number of columns. |
417 | + - Fixed PostgreSQL version detection. |
418 | + - Fixed ZPsycopgDA version check. |
419 | + - Fixed regression in ZPsycopgDA that made it behave wrongly when |
420 | + receiving serialization errors: now the query is re-issued as it |
421 | + should be by propagating the correct exception to Zope. |
422 | + - Writing "large" large objects should now work. |
423 | + |
424 | + |
425 | +What's new in psycopg 2.0.11 |
426 | +---------------------------- |
427 | + |
428 | +* New features: |
429 | + - DictRow and RealDictRow now use less memory. If you inherit on them |
430 | + remember to set __slots__ for your new attributes or be prepare to |
431 | + go back to old memory usage. |
432 | + |
433 | +* Bug fixes: |
434 | + - Fixed exeception in setup.py. |
435 | + - More robust detection of PostgreSQL development versions. |
436 | + - Fixed exception in RealDictCursor, introduced in 2.0.10. |
437 | + |
438 | + |
439 | +What's new in psycopg 2.0.10 |
440 | +---------------------------- |
441 | + |
442 | +* New features: |
443 | + - A specialized type-caster that can parse time zones with seconds is |
444 | + now available. Note that after enabling it (see extras.py) "wrong" |
445 | + time zones will be parsed without raising an exception but the |
446 | + result will be rounded. |
447 | + - DictCursor can be used as a named cursor. |
448 | + - DictRow now implements more dict methods. |
449 | + - The connection object now expose PostgreSQL server version as the |
450 | + .server_version attribute and the protocol version used as |
451 | + .protocol_version. |
452 | + - The connection object has a .get_parameter_status() methods that |
453 | + can be used to obtain useful information from the server. |
454 | + |
455 | +* Bug fixes: |
456 | + - None is now correctly always adapted to NULL. |
457 | + - Two double memory free errors provoked by multithreading and |
458 | + garbage collection are now fixed. |
459 | + - Fixed usage of internal Python code in the notice processor; this |
460 | + should fix segfaults when receiving a lot of notices in |
461 | + multithreaded programs. |
462 | + - Should build again on MSVC and Solaris. |
463 | + - Should build with development versions of PostgreSQL (ones with |
464 | + -devel version string.) |
465 | + - Fixed some tests that failed even when psycopg was right. |
466 | + |
467 | + |
468 | +What's new in psycopg 2.0.9 |
469 | +--------------------------- |
470 | + |
471 | +* New features: |
472 | + - "import psycopg2.extras" to get some support for handling times |
473 | + and timestamps with seconds in the time zone offset. |
474 | + - DictCursors can now be used as named cursors. |
475 | + |
476 | +* Bug fixes: |
477 | + - register_type() now accept an explicit None as its second parameter. |
478 | + - psycopg2 should build again on MSVC and Solaris. |
479 | + |
480 | + |
481 | +What's new in psycopg 2.0.9 |
482 | +--------------------------- |
483 | + |
484 | +* New features: |
485 | + - COPY TO/COPY FROM queries now can be of any size and psycopg will |
486 | + correctly quote separators. |
487 | + - float values Inf and NaN are now correctly handled and can |
488 | + round-trip to the database. |
489 | + - executemany() now return the numer of total INSERTed or UPDATEd |
490 | + rows. Note that, as it has always been, executemany() should not |
491 | + be used to execute multiple SELECT statements and while it will |
492 | + execute the statements without any problem, it will return the |
493 | + wrong value. |
494 | + - copy_from() and copy_to() can now use quoted separators. |
495 | + - "import psycopg2.extras" to get UUID support. |
496 | + |
497 | +* Bug fixes: |
498 | + - register_type() now works on connection and cursor subclasses. |
499 | + - fixed a memory leak when using lobjects. |
500 | + |
501 | + |
502 | +What's new in psycopg 2.0.8 |
503 | +--------------------------- |
504 | + |
505 | +* New features: |
506 | + - The connection object now has a get_backend_pid() method that |
507 | + returns the current PostgreSQL connection backend process PID. |
508 | + - The PostgreSQL large object API has been exposed through the |
509 | + Cursor.lobject() method. |
510 | + |
511 | +* Bug fixes: |
512 | + - Some fixes to ZPsycopgDA have been merged from the Debian package. |
513 | + - A memory leak was fixed in Cursor.executemany(). |
514 | + - A double free was fixed in pq_complete_error(), that caused crashes |
515 | + under some error conditions. |
516 | + |
517 | +What's new in psycopg 2.0.7 |
518 | +--------------------------- |
519 | + |
520 | +* Improved error handling: |
521 | + - All instances of psycopg2.Error subclasses now have pgerror, |
522 | + pgcode and cursor attributes. They will be set to None if no |
523 | + value is available. |
524 | + - Exception classes are now chosen based on the SQLSTATE value from |
525 | + the result. (#184) |
526 | + - The commit() and rollback() methods now set the pgerror and pgcode |
527 | + attributes on exceptions. (#152) |
528 | + - errors from commit() and rollback() are no longer considered |
529 | + fatal. (#194) |
530 | + - If a disconnect is detected during execute(), an exception will be |
531 | + raised at that point rather than resulting in "ProgrammingError: |
532 | + no results to fetch" later on. (#186) |
533 | + |
534 | +* Better PostgreSQL compatibility: |
535 | + - If the server uses standard_conforming_strings, perform |
536 | + appropriate quoting. |
537 | + - BC dates are now handled if psycopg is compiled with mxDateTime |
538 | + support. If using datetime, an appropriate ValueError is |
539 | + raised. (#203) |
540 | + |
541 | +* Other bug fixes: |
542 | + - If multiple sub-interpreters are in use, do not share the Decimal |
543 | + type between them. (#192) |
544 | + - Buffer objects obtained from psycopg are now accepted by psycopg |
545 | + too, without segfaulting. (#209) |
546 | + - A few small changes were made to improve DB-API compatibility. |
547 | + All the dbapi20 tests now pass. |
548 | + |
549 | +* Miscellaneous: |
550 | + - The PSYCOPG_DISPLAY_SIZE option is now off by default. This means |
551 | + that display size will always be set to "None" in |
552 | + cursor.description. Calculating the display size was expensive, |
553 | + and infrequently used so this should improve performance. |
554 | + - New QueryCanceledError and TransactionRollbackError exceptions |
555 | + have been added to the psycopg2.extensions module. They can be |
556 | + used to detect statement timeouts and deadlocks respectively. |
557 | + - Cursor objects now have a "closed" attribute. (#164) |
558 | + - If psycopg has been built with debug support, it is now necessary |
559 | + to set the PSYCOPG_DEBUG environment variable to turn on debug |
560 | + spew. |
561 | + |
562 | +What's new in psycopg 2.0.6 |
563 | +--------------------------- |
564 | + |
565 | +* Better support for PostgreSQL, Python and win32: |
566 | + - full support for PostgreSQL 8.2, including NULLs in arrays |
567 | + - support for almost all existing PostgreSQL encodings |
568 | + - full list of PostgreSQL error codes available by importing the |
569 | + psycopg2.errorcodes module |
570 | + - full support for Python 2.5 and 64 bit architectures |
571 | + - better build support on win32 platform |
572 | + |
573 | +* Support for per-connection type-casters (used by ZPsycopgDA too, this |
574 | + fixes a long standing bug that made different connections use a random |
575 | + set of date/time type-casters instead of the configured one.) |
576 | + |
577 | +* Better management of times and dates both from Python and in Zope. |
578 | + |
579 | +* copy_to and copy_from now take an extra "columns" parameter. |
580 | + |
581 | +* Python tuples are now adapted to SQL sequences that can be used with |
582 | + the "IN" operator by default if the psycopg2.extensions module is |
583 | + imported (i.e., the SQL_IN adapter was moved from extras to extensions.) |
584 | + |
585 | +* Fixed some small buglets and build glitches: |
586 | + - removed double mutex destroy |
587 | + - removed all non-constant initializers |
588 | + - fixed PyObject_HEAD declarations to avoid memory corruption |
589 | + on 64 bit architectures |
590 | + - fixed several Python API calls to work on 64 bit architectures |
591 | + - applied compatibility macros from PEP 353 |
592 | + - now using more than one argument format raise an error instead of |
593 | + a segfault |
594 | + |
595 | +What's new in psycopg 2.0.5.1 |
596 | +---------------------------- |
597 | + |
598 | +* Now it really, really builds on MSVC and older gcc versions. |
599 | + |
600 | +What's new in psycopg 2.0.5 |
601 | +-------------------------- |
602 | + |
603 | +* Fixed various buglets such as: |
604 | + - segfault when passing an empty string to Binary() |
605 | + - segfault on null queries |
606 | + - segfault and bad keyword naming in .executemany() |
607 | + - OperationalError in connection objects was always None |
608 | + |
609 | +* Various changes to ZPsycopgDA to make it more zope2.9-ish. |
610 | + |
611 | +* connect() now accept both integers and strings as port parameter |
612 | + |
613 | +What's new in psycopg 2.0.4 |
614 | +--------------------------- |
615 | + |
616 | +* Fixed float conversion bug introduced in 2.0.3. |
617 | + |
618 | +What's new in psycopg 2.0.3 |
619 | +--------------------------- |
620 | + |
621 | +* Fixed various buglets and a memory leak (see ChangeLog for details) |
622 | + |
623 | +What's new in psycopg 2.0.2 |
624 | +--------------------------- |
625 | + |
626 | +* Fixed a bug in array typecasting that sometimes made psycopg forget about |
627 | + the last element in the array. |
628 | + |
629 | +* Fixed some minor buglets in string memory allocations. |
630 | + |
631 | +* Builds again with compilers different from gcc (#warning about PostgreSQL |
632 | + version is issued only if __GCC__ is defined.) |
633 | + |
634 | +What's new in psycopg 2.0.1 |
635 | +--------------------------- |
636 | + |
637 | +* ZPsycopgDA now actually loads. |
638 | + |
639 | +What's new in psycopg 2.0 |
640 | +------------------------- |
641 | + |
642 | +* Fixed handle leak on win32. |
643 | + |
644 | +* If available the new "safe" encoding functions of libpq are used. |
645 | + |
646 | +* django and tinyerp people, please switch to psycopg 2 _without_ |
647 | + using a psycopg 1 compatibility layer (this release was anticipated |
648 | + so that you all stop grumbling about psycopg 2 is still in beta.. :) |
649 | + |
650 | +What's new in psycopg 2.0 beta 7 |
651 | +-------------------------------- |
652 | + |
653 | +* Ironed out last problems with times and date (should be quite solid now.) |
654 | + |
655 | +* Fixed problems with some arrays. |
656 | + |
657 | +* Slightly better ZPsycopgDA (no more double connection objects in the menu |
658 | + and other minor fixes.) |
659 | + |
660 | +* ProgrammingError exceptions now have three extra attributes: .cursor |
661 | + (it is possible to access the query that caused the exception using |
662 | + error.cursor.query), .pgerror and .pgcode (PostgreSQL original error |
663 | + text and code.) |
664 | + |
665 | +* The build system uses pg_config when available. |
666 | + |
667 | +* Documentation in the doc/ directory! (With many kudos to piro.) |
668 | + |
669 | +What's new in psycopg 2.0 beta 6 |
670 | +-------------------------------- |
671 | + |
672 | +* Support for named cursors (see examples/fetch.py). |
673 | + |
674 | +* Safer parsing of time intervals. |
675 | + |
676 | +* Better parsing of times and dates, no more locale problems. |
677 | + |
678 | +* Should now play well with py2exe and similar tools. |
679 | + |
680 | +* The "decimal" module is now used if available under Python 2.3. |
681 | + |
682 | +What's new in psycopg 2.0 beta 5 |
683 | +-------------------------------- |
684 | + |
685 | +* Fixed all known bugs. |
686 | + |
687 | +* The initial isolation level is now read from the server and |
688 | + .set_isolation_level() now takes values defined in psycopg2.extensions. |
689 | + |
690 | +* .callproc() implemented as a SELECT of the given procedure. |
691 | + |
692 | +* Better docstrings for a few functions/methods. |
693 | + |
694 | +* Some time-related functions like psycopg2.TimeFromTicks() now take the |
695 | + local timezone into account. Also a tzinfo object (as per datetime module |
696 | + specifications) can be passed to the psycopg2.Time and psycopg2.Datetime |
697 | + constructors. |
698 | + |
699 | +* All classes have been renamed to exist in the psycopg2._psycopg module, |
700 | + to fix problems with automatic documentation generators like epydoc. |
701 | + |
702 | +* NOTIFY is correctly trapped (see examples/notify.py for example code.) |
703 | + |
704 | +What's new in psycopg 2.0 beta 4 |
705 | +-------------------------------- |
706 | + |
707 | +* psycopg module is now named psycopg2. |
708 | + |
709 | +* No more segfaults when a UNICODE query can't be converted to the |
710 | + backend encoding. |
711 | + |
712 | +* No more segfaults on empty queries. |
713 | + |
714 | +* psycopg2.connect() now takes an integer for the port keyword parameter. |
715 | + |
716 | +* "python setup.py bdist_rpm" now works. |
717 | + |
718 | +* Fixed lots of small bugs, see ChangeLog for details. |
719 | + |
720 | +What's new in psycopg 2.0 beta 3 |
721 | +-------------------------------- |
722 | + |
723 | +* ZPsycopgDA now works (except table browsing.) |
724 | + |
725 | +* psycopg build again on Python 2.2. |
726 | + |
727 | +What's new in psycopg 2.0 beta 2 |
728 | +-------------------------------- |
729 | + |
730 | +* Fixed ZPsycopgDA version check (ZPsycopgDA can now be imported in |
731 | + Zope.) |
732 | + |
733 | +* psycopg.extras.DictRow works even after a new query on the generating |
734 | + cursor. |
735 | + |
736 | +* Better setup.py for win32 (should build with MSCV or mingw.) |
737 | + |
738 | +* Generic fixed and memory leaks plugs. |
739 | + |
740 | +What's new in psycopg 2.0 beta 1 |
741 | +-------------------------------- |
742 | + |
743 | +* Officially in beta (i.e., no new features will be added.) |
744 | + |
745 | +* Array support: list objects can be passed as bound variables and are |
746 | + correctly returned for array columns. |
747 | + |
748 | +* Added the psycopg.psycopg1 compatibility module (if you want instant |
749 | + psycopg 1 compatibility just "from psycopg import psycopg1 as psycopg".) |
750 | + |
751 | +* Complete support for BYTEA columns and buffer objects. |
752 | + |
753 | +* Added error codes to error messages. |
754 | + |
755 | +* The AsIs adapter is now exported by default (also Decimal objects are |
756 | + adapted using the AsIs adapter (when str() is called on them they |
757 | + already format themselves using the right precision and scale.) |
758 | + |
759 | +* The connect() function now takes "connection_factory" instead of |
760 | + "factory" as keyword argument. |
761 | + |
762 | +* New setup.py code to build on win32 using mingw and better error |
763 | + messages on missing datetime headers, |
764 | + |
765 | +* Internal changes that allow much better user-defined type casters. |
766 | + |
767 | +* A lot of bugfixes (binary, datetime, 64 bit arches, GIL, .executemany()) |
768 | + |
769 | +What's new in psycopg 1.99.13 |
770 | +----------------------------- |
771 | + |
772 | +* Added missing .executemany() method. |
773 | + |
774 | +* Optimized type cast from PostgreSQL to Python (psycopg should be even |
775 | + faster than before.) |
776 | + |
777 | +What's new in psycopg 1.99.12 |
778 | +----------------------------- |
779 | + |
780 | +* .rowcount should be ok and in sync with psycopg 1. |
781 | + |
782 | +* Implemented the new COPY FROM/COPY TO code when connection to the |
783 | + backend using libpq protocol 3 (this also removes all asprintf calls: |
784 | + build on win32 works again.) A protocol 3-enabled psycopg *can* |
785 | + connect to an old protocol 2 database and will detect it and use the |
786 | + right code. |
787 | + |
788 | +* getquoted() called for real by the mogrification code. |
789 | + |
790 | +What's new in psycopg 1.99.11 |
791 | +----------------------------- |
792 | + |
793 | +* 'cursor' argument in .cursor() connection method renamed to |
794 | + 'cursor_factory'. |
795 | + |
796 | +* changed 'tuple_factory' cursor attribute name to 'row_factory'. |
797 | + |
798 | +* the .cursor attribute is gone and connections and cursors are propely |
799 | + gc-managed. |
800 | + |
801 | +* fixes to the async core. |
802 | + |
803 | +What's new in psycopg 1.99.10 |
804 | +----------------------------- |
805 | + |
806 | +* The adapt() function now fully supports the adaptation protocol |
807 | + described in PEP 246. Note that the adapters registry now is indexed |
808 | + by (type, protocol) and not by type alone. Change your adapters |
809 | + accordingly. |
810 | + |
811 | +* More configuration options moved from setup.py to setup.cfg. |
812 | + |
813 | +* Fixed two memory leaks: one in cursor deallocation and one in row |
814 | + fetching (.fetchXXX() methods.) |
815 | + |
816 | +What's new in psycopg 1.99.9 |
817 | +---------------------------- |
818 | + |
819 | +* Added simple pooling code (psycopg.pool module); see the reworked |
820 | + examples/threads.py for example code. |
821 | + |
822 | +* Added DECIMAL typecaster to convert postgresql DECIMAL and NUMERIC |
823 | + types (i.e, all types with an OID of NUMERICOID.) Note that the |
824 | + DECIMAL typecaster does not set scale and precision on the created |
825 | + objects but uses Python defaults. |
826 | + |
827 | +* ZPsycopgDA back in and working using the new pooling code. |
828 | + |
829 | +* Isn't that enough? :) |
830 | + |
831 | +What's new in psycopg 1.99.8 |
832 | +---------------------------- |
833 | + |
834 | +* added support for UNICODE queries. |
835 | + |
836 | +* added UNICODE typecaster; to activate it just do: |
837 | + |
838 | + psycopg.extensions.register_type(psycopg.extensions.UNICODE) |
839 | + |
840 | + Note that the UNICODE typecaster override the STRING one, so it is |
841 | + not activated by default. |
842 | + |
843 | +* cursors now really support the iterator protocol. |
844 | + |
845 | +* solved the rounding errors in time conversions. |
846 | + |
847 | +* now cursors support .fileno() and .isready() methods, to be used in |
848 | + select() calls. |
849 | + |
850 | +* .copy_from() and .copy_in() methods are back in (still using the old |
851 | + protocol, will be updated to use new one in next releasae.) |
852 | + |
853 | +* fixed memory corruption bug reported on win32 platform. |
854 | + |
855 | +What's new in psycopg 1.99.7 |
856 | +---------------------------- |
857 | + |
858 | +* added support for tuple factories in cursor objects (removed factory |
859 | + argument in favor of a .tuple_factory attribute on the cursor object); |
860 | + see the new module psycopg.extras for a cursor (DictCursor) that |
861 | + return rows as objects that support indexing both by position and |
862 | + column name. |
863 | + |
864 | +* added support for tzinfo objects in datetime.timestamp objects: the |
865 | + PostgreSQL type "timestamp with time zone" is converted to |
866 | + datetime.timestamp with a FixedOffsetTimezone initialized as necessary. |
867 | + |
868 | +What's new in psycopg 1.99.6 |
869 | +---------------------------- |
870 | + |
871 | +* sslmode parameter from 1.1.x |
872 | + |
873 | +* various datetime conversion improvements. |
874 | + |
875 | +* now psycopg should compile without mx or without native datetime |
876 | + (not both, obviously.) |
877 | + |
878 | +* included various win32/MSVC fixes (pthread.h changes, winsock2 |
879 | + library, include path in setup.py, etc.) |
880 | + |
881 | +* ported interval fixes from 1.1.14/1.1.15. |
882 | + |
883 | +* the last query executed by a cursor is now available in the |
884 | + .query attribute. |
885 | + |
886 | +* conversion of unicode strings to backend encoding now uses a table |
887 | + (that still need to be filled.) |
888 | + |
889 | +* cursors now have a .mogrify() method that return the query string |
890 | + instead of executing it. |
891 | + |
892 | +* connection objects now have a .dsn read-only attribute that holds the |
893 | + connection string. |
894 | + |
895 | +* moved psycopg C module to _psycopg and made psycopg a python module: |
896 | + this allows for a neat separation of DBAPI-2.0 functionality and psycopg |
897 | + extensions; the psycopg namespace will be also used to provide |
898 | + python-only extensions (like the pooling code, some ZPsycopgDA support |
899 | + functions and the like.) |
900 | + |
901 | +What's new in psycopg 1.99.3 |
902 | +---------------------------- |
903 | + |
904 | +* added support for python 2.3 datetime types (both ways) and made datetime |
905 | + the default set of typecasters when available. |
906 | + |
907 | +* added example: dt.py. |
908 | + |
909 | +What's new in psycopg 1.99.3 |
910 | +---------------------------- |
911 | + |
912 | +* initial working support for unicode bound variables: UTF-8 and latin-1 |
913 | + backend encodings are natively supported (and the encoding.py example even |
914 | + works!) |
915 | + |
916 | +* added .set_client_encoding() method on the connection object. |
917 | + |
918 | +* added examples: encoding.py, binary.py, lastrowid.py. |
919 | + |
920 | +What's new in psycopg 1.99.2 |
921 | +---------------------------- |
922 | + |
923 | +* better typecasting: |
924 | + - DateTimeDelta used for postgresql TIME (merge from 1.1) |
925 | + - BYTEA now is converted to a real buffer object, not to a string |
926 | + |
927 | +* buffer objects are now adapted into Binary objects automatically. |
928 | + |
929 | +* ported scroll method from 1.1 (DBAPI-2.0 extension for cursors) |
930 | + |
931 | +* initial support for some DBAPI-2.0 extensions: |
932 | + - .rownumber attribute for cursors |
933 | + - .connection attribute for cursors |
934 | + - .next() and .__iter__() methods to have cursors support the iterator |
935 | + protocol |
936 | + - all exception objects are exported to the connection object |
937 | + |
938 | +What's new in psycopg 1.99.1 |
939 | +---------------------------- |
940 | + |
941 | +* implemented microprotocols to adapt arbitrary types to the interface used by |
942 | + psycopg to bind variables in execute; |
943 | + |
944 | +* moved qstring, pboolean and mxdatetime to the new adapter layout (binary is |
945 | + still missing; python 2.3 datetime needs to be written). |
946 | + |
947 | + |
948 | +What's new in psycopg 1.99.0 |
949 | +---------------------------- |
950 | + |
951 | +* reorganized the whole source tree; |
952 | + |
953 | +* async core is in place; |
954 | + |
955 | +* splitted QuotedString objects from mx stuff; |
956 | + |
957 | +* dropped autotools and moved to pythonic setup.py (needs work.) |
958 | |
959 | === added file 'NEWS-2.2' |
960 | --- NEWS-2.2 1970-01-01 00:00:00 +0000 |
961 | +++ NEWS-2.2 2010-07-28 20:35:51 +0000 |
962 | @@ -0,0 +1,39 @@ |
963 | +What's new in psycopg 2.2.1 |
964 | +--------------------------- |
965 | + |
966 | +* Bux fixes: |
967 | + - psycopg now builds again on MS Windows. |
968 | + |
969 | + |
970 | +What's new in psycopg 2.2.0 |
971 | +--------------------------- |
972 | + |
973 | +This is the first release of the new 2.2 series, supporting not just one but |
974 | +two different ways of executing asynchronous queries, thanks to Jan and Daniele |
975 | +(with a little help from me and others, but they did 99% of the work so they |
976 | +deserve their names here in the news.) |
977 | + |
978 | +psycopg now supports both classic select() loops and "green" coroutine |
979 | +libraries. It is all in the documentation, so just point your browser to |
980 | +doc/html/advanced.html. |
981 | + |
982 | +* Other new features: |
983 | + - truncate() method for lobjects. |
984 | + - COPY functions are now a little bit faster. |
985 | + - All builtin PostgreSQL to Python typecasters are now available from the |
986 | + psycopg2.extensions module. |
987 | + - Notifications from the backend are now available right after the execute() |
988 | + call (before client code needed to call isbusy() to ensure NOTIFY |
989 | + reception.) |
990 | + - Better timezone support. |
991 | + - Lots of documentation updates. |
992 | + |
993 | +* Bug fixes: |
994 | + - Fixed some gc/refcounting problems. |
995 | + - Fixed reference leak in NOTIFY reception. |
996 | + - Fixed problem with PostgreSQL not casting string literals to the correct |
997 | + types in some situations: psycopg now add an explicit cast to dates, times |
998 | + and bytea representations. |
999 | + - Fixed TimestampFromTicks() and TimeFromTicks() for seconds >= 59.5. |
1000 | + - Fixed spurious exception raised when calling C typecasters from Python |
1001 | + ones. |
1002 | |
1003 | === modified file 'PKG-INFO' |
1004 | --- PKG-INFO 2009-10-12 06:50:00 +0000 |
1005 | +++ PKG-INFO 2010-07-28 20:35:51 +0000 |
1006 | @@ -1,6 +1,6 @@ |
1007 | Metadata-Version: 1.0 |
1008 | Name: psycopg2 |
1009 | -Version: 2.0.13 |
1010 | +Version: 2.2.1 |
1011 | Summary: Python-PostgreSQL Database Adapter |
1012 | Home-page: http://initd.org/tracker/psycopg |
1013 | Author: Federico Di Gregorio |
1014 | @@ -20,9 +20,9 @@ |
1015 | brave programmer. |
1016 | |
1017 | Platform: any |
1018 | -Classifier: Development Status :: 4 - Beta |
1019 | +Classifier: Development Status :: 5 - Production/Stable |
1020 | Classifier: Intended Audience :: Developers |
1021 | -Classifier: License :: OSI Approved :: GNU General Public License (GPL) |
1022 | +Classifier: License :: OSI Approved :: GNU Lesser General Public License (LGPL) |
1023 | Classifier: License :: OSI Approved :: Zope Public License |
1024 | Classifier: Programming Language :: Python |
1025 | Classifier: Programming Language :: C |
1026 | |
1027 | === modified file 'README' |
1028 | --- README 2006-08-09 10:28:30 +0000 |
1029 | +++ README 2010-07-28 20:35:51 +0000 |
1030 | @@ -1,28 +1,32 @@ |
1031 | -psycopg - Python-PostgreSQL Database Adapter |
1032 | +psycopg2 - Python-PostgreSQL Database Adapter |
1033 | ******************************************** |
1034 | |
1035 | -psycopg is a PostgreSQL database adapter for the Python programming |
1036 | +psycopg2 is a PostgreSQL database adapter for the Python programming |
1037 | language. This is version 2, a complete rewrite of the original code to |
1038 | provide new-style classes for connection and cursor objects and other |
1039 | -sweet candies. Like the original, psycopg 2 was written with the aim of |
1040 | +sweet candies. Like the original, psycopg2 was written with the aim of |
1041 | being very small and fast, and stable as a rock. |
1042 | |
1043 | -psycopg is different from the other database adapter because it was |
1044 | +psycopg2 is different from the other database adapter because it was |
1045 | designed for heavily multi-threaded applications that create and destroy |
1046 | lots of cursors and make a conspicuous number of concurrent INSERTs or |
1047 | -UPDATEs. psycopg 2 also provide full asycronous operations for the really |
1048 | +UPDATEs. psycopg2 also provide full asycronous operations for the really |
1049 | brave programmer. |
1050 | |
1051 | There are confirmed reports of psycopg 1.x compiling and running on Linux |
1052 | -and FreeBSD on i386, Solaris, MacOS X and win32 architectures. psycopg 2 |
1053 | +and FreeBSD on i386, Solaris, MacOS X and win32 architectures. psycopg2 |
1054 | does not introduce build-wise incompatible changes so it should be able to |
1055 | compile on all architectures just as its predecessor did. |
1056 | |
1057 | -Now go read the INSTALL file. More information about psycopg extensions to |
1058 | +Now go read the INSTALL file. More information about psycopg2 extensions to |
1059 | the DBAPI-2.0 is available in the files located in the doc/ direcory. |
1060 | +Example code can be found in the examples/ directory. If you make any changes |
1061 | +to the code make sure to run the unit tests localed in tests/. |
1062 | |
1063 | -psycopg is free software ("free as in freedom" but I like beer too.) |
1064 | -Licensing information is available in the LICENSE file. |
1065 | +psycopg2 is free software ("free as in freedom" but I like beer too.) |
1066 | +It is licensed under the GNU Lesser General Public License, version 3 or |
1067 | +later plus an exception to allow OpenSSL (libpq) linking; see LICENSE for |
1068 | +more details. |
1069 | |
1070 | |
1071 | Contributors |
1072 | |
1073 | === modified file 'ZPsycopgDA/DA.py' |
1074 | --- ZPsycopgDA/DA.py 2009-10-12 06:50:00 +0000 |
1075 | +++ ZPsycopgDA/DA.py 2010-07-28 20:35:51 +0000 |
1076 | @@ -1,24 +1,22 @@ |
1077 | # ZPsycopgDA/DA.py - ZPsycopgDA Zope product: Database Connection |
1078 | # |
1079 | -# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org> |
1080 | -# |
1081 | -# This program is free software; you can redistribute it and/or modify |
1082 | -# it under the terms of the GNU General Public License as published by the |
1083 | -# Free Software Foundation; either version 2, or (at your option) any later |
1084 | -# version. |
1085 | -# |
1086 | -# Or, at your option this program (ZPsycopgDA) can be distributed under the |
1087 | -# Zope Public License (ZPL) Version 1.0, as published on the Zope web site, |
1088 | -# http://www.zope.org/Resources/ZPL. |
1089 | -# |
1090 | -# This program is distributed in the hope that it will be useful, but |
1091 | -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY |
1092 | -# or FITNESS FOR A PARTICULAR PURPOSE. |
1093 | -# |
1094 | -# See the LICENSE file for details. |
1095 | - |
1096 | - |
1097 | -ALLOWED_PSYCOPG_VERSIONS = ('2.0.7','2.0.8','2.0.9','2.0.10', '2.0.11', '2.0.12', '2.0.13') |
1098 | +# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org> |
1099 | +# |
1100 | +# psycopg2 is free software: you can redistribute it and/or modify it |
1101 | +# under the terms of the GNU Lesser General Public License as published |
1102 | +# by the Free Software Foundation, either version 3 of the License, or |
1103 | +# (at your option) any later version. |
1104 | +# |
1105 | +# psycopg2 is distributed in the hope that it will be useful, but WITHOUT |
1106 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1107 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
1108 | +# License for more details. |
1109 | + |
1110 | +# Import modules needed by _psycopg to allow tools like py2exe to do |
1111 | +# their work without bothering about the module dependencies. |
1112 | + |
1113 | + |
1114 | +ALLOWED_PSYCOPG_VERSIONS = ('2.2.0','2.2.1') |
1115 | |
1116 | import sys |
1117 | import time |
1118 | |
1119 | === modified file 'ZPsycopgDA/__init__.py' |
1120 | --- ZPsycopgDA/__init__.py 2006-08-09 10:28:30 +0000 |
1121 | +++ ZPsycopgDA/__init__.py 2010-07-28 20:35:51 +0000 |
1122 | @@ -1,21 +1,19 @@ |
1123 | # ZPsycopgDA/__init__.py - ZPsycopgDA Zope product |
1124 | # |
1125 | -# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org> |
1126 | -# |
1127 | -# This program is free software; you can redistribute it and/or modify |
1128 | -# it under the terms of the GNU General Public License as published by the |
1129 | -# Free Software Foundation; either version 2, or (at your option) any later |
1130 | -# version. |
1131 | -# |
1132 | -# Or, at your option this program (ZPsycopgDA) can be distributed under the |
1133 | -# Zope Public License (ZPL) Version 1.0, as published on the Zope web site, |
1134 | -# http://www.zope.org/Resources/ZPL. |
1135 | -# |
1136 | -# This program is distributed in the hope that it will be useful, but |
1137 | -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY |
1138 | -# or FITNESS FOR A PARTICULAR PURPOSE. |
1139 | -# |
1140 | -# See the LICENSE file for details. |
1141 | +# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org> |
1142 | +# |
1143 | +# psycopg2 is free software: you can redistribute it and/or modify it |
1144 | +# under the terms of the GNU Lesser General Public License as published |
1145 | +# by the Free Software Foundation, either version 3 of the License, or |
1146 | +# (at your option) any later version. |
1147 | +# |
1148 | +# psycopg2 is distributed in the hope that it will be useful, but WITHOUT |
1149 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1150 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
1151 | +# License for more details. |
1152 | + |
1153 | +# Import modules needed by _psycopg to allow tools like py2exe to do |
1154 | +# their work without bothering about the module dependencies. |
1155 | |
1156 | __doc__ = "ZPsycopg Database Adapter Registration." |
1157 | __version__ = '2.0' |
1158 | |
1159 | === modified file 'ZPsycopgDA/db.py' |
1160 | --- ZPsycopgDA/db.py 2009-08-27 18:05:48 +0000 |
1161 | +++ ZPsycopgDA/db.py 2010-07-28 20:35:51 +0000 |
1162 | @@ -1,21 +1,19 @@ |
1163 | # ZPsycopgDA/db.py - query execution |
1164 | # |
1165 | -# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org> |
1166 | -# |
1167 | -# This program is free software; you can redistribute it and/or modify |
1168 | -# it under the terms of the GNU General Public License as published by the |
1169 | -# Free Software Foundation; either version 2, or (at your option) any later |
1170 | -# version. |
1171 | -# |
1172 | -# Or, at your option this program (ZPsycopgDA) can be distributed under the |
1173 | -# Zope Public License (ZPL) Version 1.0, as published on the Zope web site, |
1174 | -# http://www.zope.org/Resources/ZPL. |
1175 | -# |
1176 | -# This program is distributed in the hope that it will be useful, but |
1177 | -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY |
1178 | -# or FITNESS FOR A PARTICULAR PURPOSE. |
1179 | -# |
1180 | -# See the LICENSE file for details. |
1181 | +# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org> |
1182 | +# |
1183 | +# psycopg2 is free software: you can redistribute it and/or modify it |
1184 | +# under the terms of the GNU Lesser General Public License as published |
1185 | +# by the Free Software Foundation, either version 3 of the License, or |
1186 | +# (at your option) any later version. |
1187 | +# |
1188 | +# psycopg2 is distributed in the hope that it will be useful, but WITHOUT |
1189 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1190 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
1191 | +# License for more details. |
1192 | + |
1193 | +# Import modules needed by _psycopg to allow tools like py2exe to do |
1194 | +# their work without bothering about the module dependencies. |
1195 | |
1196 | from Shared.DC.ZRDB.TM import TM |
1197 | from Shared.DC.ZRDB import dbi_db |
1198 | @@ -171,15 +169,15 @@ |
1199 | c.execute(qs) |
1200 | except TransactionRollbackError: |
1201 | # Ha, here we have to look like we are the ZODB raising conflict errrors, raising ZPublisher.Publish.Retry just doesn't work |
1202 | - logging.debug("Serialization Error, retrying transaction", exc_info=True) |
1203 | + #logging.debug("Serialization Error, retrying transaction", exc_info=True) |
1204 | raise ConflictError("TransactionRollbackError from psycopg2") |
1205 | except psycopg2.OperationalError: |
1206 | - logging.exception("Operational error on connection, closing it.") |
1207 | + #logging.exception("Operational error on connection, closing it.") |
1208 | try: |
1209 | # Only close our connection |
1210 | self.putconn(True) |
1211 | except: |
1212 | - logging.debug("Something went wrong when we tried to close the pool", exc_info=True) |
1213 | + #logging.debug("Something went wrong when we tried to close the pool", exc_info=True) |
1214 | pass |
1215 | if c.description is not None: |
1216 | nselects += 1 |
1217 | |
1218 | === modified file 'ZPsycopgDA/pool.py' |
1219 | --- ZPsycopgDA/pool.py 2006-08-09 10:28:30 +0000 |
1220 | +++ ZPsycopgDA/pool.py 2010-07-28 20:35:51 +0000 |
1221 | @@ -1,24 +1,22 @@ |
1222 | # ZPsycopgDA/pool.py - ZPsycopgDA Zope product: connection pooling |
1223 | # |
1224 | -# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org> |
1225 | -# |
1226 | -# This program is free software; you can redistribute it and/or modify |
1227 | -# it under the terms of the GNU General Public License as published by the |
1228 | -# Free Software Foundation; either version 2, or (at your option) any later |
1229 | -# version. |
1230 | -# |
1231 | -# Or, at your option this program (ZPsycopgDA) can be distributed under the |
1232 | -# Zope Public License (ZPL) Version 1.0, as published on the Zope web site, |
1233 | -# http://www.zope.org/Resources/ZPL. |
1234 | -# |
1235 | -# This program is distributed in the hope that it will be useful, but |
1236 | -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY |
1237 | -# or FITNESS FOR A PARTICULAR PURPOSE. |
1238 | -# |
1239 | -# See the LICENSE file for details. |
1240 | - |
1241 | -# all the connections are held in a pool of pools, directly accessible by the |
1242 | -# ZPsycopgDA code in db.py |
1243 | +# Copyright (C) 2004-2010 Federico Di Gregorio <fog@debian.org> |
1244 | +# |
1245 | +# psycopg2 is free software: you can redistribute it and/or modify it |
1246 | +# under the terms of the GNU Lesser General Public License as published |
1247 | +# by the Free Software Foundation, either version 3 of the License, or |
1248 | +# (at your option) any later version. |
1249 | +# |
1250 | +# psycopg2 is distributed in the hope that it will be useful, but WITHOUT |
1251 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1252 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
1253 | +# License for more details. |
1254 | + |
1255 | +# Import modules needed by _psycopg to allow tools like py2exe to do |
1256 | +# their work without bothering about the module dependencies. |
1257 | + |
1258 | +# All the connections are held in a pool of pools, directly accessible by the |
1259 | +# ZPsycopgDA code in db.py. |
1260 | |
1261 | import threading |
1262 | import psycopg2.pool |
1263 | |
1264 | === modified file 'debian/changelog' |
1265 | --- debian/changelog 2010-04-16 10:05:03 +0000 |
1266 | +++ debian/changelog 2010-07-28 20:35:51 +0000 |
1267 | @@ -1,3 +1,26 @@ |
1268 | +psycopg2 (2.2.1-1ubuntu1) maverick; urgency=low |
1269 | + |
1270 | + * Merge from Debian (LP: #611040). Remaining changes: |
1271 | + debian/control, debian/rules: Install a seperate testsuite package. |
1272 | + |
1273 | + -- Mikhail Turov <groldster@gmail.com> Wed, 28 Jul 2010 21:20:45 +0100 |
1274 | + |
1275 | +psycopg2 (2.2.1-1) unstable; urgency=low |
1276 | + |
1277 | + * New upstream release. (Closes: #582823) |
1278 | + * debian/control: |
1279 | + - bumped Standards-Version to 3.9.0, no changes required. |
1280 | + - removed the zope-psycopg2da binary package. (Closes: #583293) |
1281 | + |
1282 | + -- Fabio Tranchitella <kobold@debian.org> Fri, 02 Jul 2010 15:04:19 +0200 |
1283 | + |
1284 | +psycopg2 (2.0.14-1) unstable; urgency=low |
1285 | + |
1286 | + * New upstream release. |
1287 | + * debian/control: bumped Standards-Version to 3.8.5, no changes required. |
1288 | + |
1289 | + -- Fabio Tranchitella <kobold@debian.org> Sat, 10 Apr 2010 10:32:45 +0200 |
1290 | + |
1291 | psycopg2 (2.0.13-2ubuntu2) lucid; urgency=low |
1292 | |
1293 | * Drop the zope2 package as we have no zope2 in lucid. |
1294 | @@ -388,13 +411,6 @@ |
1295 | |
1296 | -- Federico Di Gregorio <fog@debian.org> Fri, 1 Aug 2003 11:50:57 +0200 |
1297 | |
1298 | -psycopg (1.1.5.1-1.1) unstable; urgency=low |
1299 | - |
1300 | - * NMU |
1301 | - * Update for python2.3 as the default python version (closes: #205746). |
1302 | - |
1303 | - -- Matthias Klose <doko@debian.org> Fri, 22 Aug 2003 00:02:25 +0200 |
1304 | - |
1305 | psycopg (1.1.7-1) unstable; urgency=low |
1306 | |
1307 | * New upstream release. |
1308 | @@ -408,6 +424,13 @@ |
1309 | |
1310 | -- Federico Di Gregorio <fog@initd.org> Sun, 13 Jul 2003 23:36:04 +0200 |
1311 | |
1312 | +psycopg (1.1.5.1-1.1) unstable; urgency=low |
1313 | + |
1314 | + * NMU |
1315 | + * Update for python2.3 as the default python version (closes: #205746). |
1316 | + |
1317 | + -- Matthias Klose <doko@debian.org> Fri, 22 Aug 2003 00:02:25 +0200 |
1318 | + |
1319 | psycopg (1.1.5.1-1) unstable; urgency=low |
1320 | |
1321 | * New upstream release. |
1322 | |
1323 | === modified file 'debian/control' |
1324 | --- debian/control 2010-04-16 10:05:03 +0000 |
1325 | +++ debian/control 2010-07-28 20:35:51 +0000 |
1326 | @@ -4,7 +4,7 @@ |
1327 | Build-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 |
1328 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
1329 | XSBC-Original-Maintainer: Fabio Tranchitella <kobold@debian.org> |
1330 | -Standards-Version: 3.8.3 |
1331 | +Standards-Version: 3.9.0 |
1332 | XS-Python-Version: all |
1333 | Vcs-Svn: svn://svn.debian.org/python-modules/packages/psycopg2/trunk/ |
1334 | Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/psycopg2/trunk/ |
1335 | @@ -13,7 +13,7 @@ |
1336 | Package: python-psycopg2 |
1337 | Architecture: any |
1338 | Section: python |
1339 | -Depends: ${python:Depends}, ${shlibs:Depends}, python-egenix-mxdatetime |
1340 | +Depends: python-egenix-mxdatetime, ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} |
1341 | Provides: ${python:Provides} |
1342 | XB-Python-Version: ${python:Versions} |
1343 | Description: Python module for PostgreSQL |
1344 | @@ -37,7 +37,7 @@ |
1345 | Priority: extra |
1346 | Architecture: any |
1347 | Section: debug |
1348 | -Depends: python-psycopg2 (= ${binary:Version}), python-dbg, ${shlibs:Depends} |
1349 | +Depends: python-psycopg2 (= ${binary:Version}), python-dbg, ${shlibs:Depends}, ${misc:Depends} |
1350 | XB-Python-Version: ${python:Versions} |
1351 | Description: Python module for PostgreSQL (debug extension) |
1352 | psycopg is a PostgreSQL database adapter for the Python programming language |
1353 | @@ -48,15 +48,6 @@ |
1354 | . |
1355 | This package contains the extensions built for the Python debug interpreter. |
1356 | |
1357 | -#Package: zope-psycopgda2 |
1358 | -#Architecture: all |
1359 | -#Section: zope |
1360 | -#Depends: ${zope:Depends}, python-psycopg2 (>= ${source:Version}) |
1361 | -#XB-Python-Version: ${python:Versions} |
1362 | -#Description: Zope database adapter based on python-psycopg2 |
1363 | -# The package contains the PostgreSQL database adapter for Zope 2.7, 2.8 and |
1364 | -# 2.9 based on the psycopg2 Python module. |
1365 | - |
1366 | Package: python-psycopg2-testsuite |
1367 | Architecture: any |
1368 | Section: python |
1369 | |
1370 | === modified file 'debian/rules' |
1371 | --- debian/rules 2010-04-16 10:05:03 +0000 |
1372 | +++ debian/rules 2010-07-28 20:35:51 +0000 |
1373 | @@ -59,8 +59,6 @@ |
1374 | find debian/python-*-dbg -depth -empty -exec rmdir {} \; |
1375 | |
1376 | install-indep: build |
1377 | - # Zope package |
1378 | - #dh_installzope -p zope-psycopgda2 ZPsycopgDA |
1379 | |
1380 | # Build architecture-independent files here. |
1381 | binary-indep: build install-indep |
1382 | |
1383 | === added directory 'debian/source' |
1384 | === added file 'debian/source/format' |
1385 | --- debian/source/format 1970-01-01 00:00:00 +0000 |
1386 | +++ debian/source/format 2010-07-28 20:35:51 +0000 |
1387 | @@ -0,0 +1,1 @@ |
1388 | +1.0 |
1389 | |
1390 | === added file 'doc/COPYING' |
1391 | --- doc/COPYING 1970-01-01 00:00:00 +0000 |
1392 | +++ doc/COPYING 2010-07-28 20:35:51 +0000 |
1393 | @@ -0,0 +1,676 @@ |
1394 | + |
1395 | + GNU GENERAL PUBLIC LICENSE |
1396 | + Version 3, 29 June 2007 |
1397 | + |
1398 | + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
1399 | + Everyone is permitted to copy and distribute verbatim copies |
1400 | + of this license document, but changing it is not allowed. |
1401 | + |
1402 | + Preamble |
1403 | + |
1404 | + The GNU General Public License is a free, copyleft license for |
1405 | +software and other kinds of works. |
1406 | + |
1407 | + The licenses for most software and other practical works are designed |
1408 | +to take away your freedom to share and change the works. By contrast, |
1409 | +the GNU General Public License is intended to guarantee your freedom to |
1410 | +share and change all versions of a program--to make sure it remains free |
1411 | +software for all its users. We, the Free Software Foundation, use the |
1412 | +GNU General Public License for most of our software; it applies also to |
1413 | +any other work released this way by its authors. You can apply it to |
1414 | +your programs, too. |
1415 | + |
1416 | + When we speak of free software, we are referring to freedom, not |
1417 | +price. Our General Public Licenses are designed to make sure that you |
1418 | +have the freedom to distribute copies of free software (and charge for |
1419 | +them if you wish), that you receive source code or can get it if you |
1420 | +want it, that you can change the software or use pieces of it in new |
1421 | +free programs, and that you know you can do these things. |
1422 | + |
1423 | + To protect your rights, we need to prevent others from denying you |
1424 | +these rights or asking you to surrender the rights. Therefore, you have |
1425 | +certain responsibilities if you distribute copies of the software, or if |
1426 | +you modify it: responsibilities to respect the freedom of others. |
1427 | + |
1428 | + For example, if you distribute copies of such a program, whether |
1429 | +gratis or for a fee, you must pass on to the recipients the same |
1430 | +freedoms that you received. You must make sure that they, too, receive |
1431 | +or can get the source code. And you must show them these terms so they |
1432 | +know their rights. |
1433 | + |
1434 | + Developers that use the GNU GPL protect your rights with two steps: |
1435 | +(1) assert copyright on the software, and (2) offer you this License |
1436 | +giving you legal permission to copy, distribute and/or modify it. |
1437 | + |
1438 | + For the developers' and authors' protection, the GPL clearly explains |
1439 | +that there is no warranty for this free software. For both users' and |
1440 | +authors' sake, the GPL requires that modified versions be marked as |
1441 | +changed, so that their problems will not be attributed erroneously to |
1442 | +authors of previous versions. |
1443 | + |
1444 | + Some devices are designed to deny users access to install or run |
1445 | +modified versions of the software inside them, although the manufacturer |
1446 | +can do so. This is fundamentally incompatible with the aim of |
1447 | +protecting users' freedom to change the software. The systematic |
1448 | +pattern of such abuse occurs in the area of products for individuals to |
1449 | +use, which is precisely where it is most unacceptable. Therefore, we |
1450 | +have designed this version of the GPL to prohibit the practice for those |
1451 | +products. If such problems arise substantially in other domains, we |
1452 | +stand ready to extend this provision to those domains in future versions |
1453 | +of the GPL, as needed to protect the freedom of users. |
1454 | + |
1455 | + Finally, every program is threatened constantly by software patents. |
1456 | +States should not allow patents to restrict development and use of |
1457 | +software on general-purpose computers, but in those that do, we wish to |
1458 | +avoid the special danger that patents applied to a free program could |
1459 | +make it effectively proprietary. To prevent this, the GPL assures that |
1460 | +patents cannot be used to render the program non-free. |
1461 | + |
1462 | + The precise terms and conditions for copying, distribution and |
1463 | +modification follow. |
1464 | + |
1465 | + TERMS AND CONDITIONS |
1466 | + |
1467 | + 0. Definitions. |
1468 | + |
1469 | + "This License" refers to version 3 of the GNU General Public License. |
1470 | + |
1471 | + "Copyright" also means copyright-like laws that apply to other kinds of |
1472 | +works, such as semiconductor masks. |
1473 | + |
1474 | + "The Program" refers to any copyrightable work licensed under this |
1475 | +License. Each licensee is addressed as "you". "Licensees" and |
1476 | +"recipients" may be individuals or organizations. |
1477 | + |
1478 | + To "modify" a work means to copy from or adapt all or part of the work |
1479 | +in a fashion requiring copyright permission, other than the making of an |
1480 | +exact copy. The resulting work is called a "modified version" of the |
1481 | +earlier work or a work "based on" the earlier work. |
1482 | + |
1483 | + A "covered work" means either the unmodified Program or a work based |
1484 | +on the Program. |
1485 | + |
1486 | + To "propagate" a work means to do anything with it that, without |
1487 | +permission, would make you directly or secondarily liable for |
1488 | +infringement under applicable copyright law, except executing it on a |
1489 | +computer or modifying a private copy. Propagation includes copying, |
1490 | +distribution (with or without modification), making available to the |
1491 | +public, and in some countries other activities as well. |
1492 | + |
1493 | + To "convey" a work means any kind of propagation that enables other |
1494 | +parties to make or receive copies. Mere interaction with a user through |
1495 | +a computer network, with no transfer of a copy, is not conveying. |
1496 | + |
1497 | + An interactive user interface displays "Appropriate Legal Notices" |
1498 | +to the extent that it includes a convenient and prominently visible |
1499 | +feature that (1) displays an appropriate copyright notice, and (2) |
1500 | +tells the user that there is no warranty for the work (except to the |
1501 | +extent that warranties are provided), that licensees may convey the |
1502 | +work under this License, and how to view a copy of this License. If |
1503 | +the interface presents a list of user commands or options, such as a |
1504 | +menu, a prominent item in the list meets this criterion. |
1505 | + |
1506 | + 1. Source Code. |
1507 | + |
1508 | + The "source code" for a work means the preferred form of the work |
1509 | +for making modifications to it. "Object code" means any non-source |
1510 | +form of a work. |
1511 | + |
1512 | + A "Standard Interface" means an interface that either is an official |
1513 | +standard defined by a recognized standards body, or, in the case of |
1514 | +interfaces specified for a particular programming language, one that |
1515 | +is widely used among developers working in that language. |
1516 | + |
1517 | + The "System Libraries" of an executable work include anything, other |
1518 | +than the work as a whole, that (a) is included in the normal form of |
1519 | +packaging a Major Component, but which is not part of that Major |
1520 | +Component, and (b) serves only to enable use of the work with that |
1521 | +Major Component, or to implement a Standard Interface for which an |
1522 | +implementation is available to the public in source code form. A |
1523 | +"Major Component", in this context, means a major essential component |
1524 | +(kernel, window system, and so on) of the specific operating system |
1525 | +(if any) on which the executable work runs, or a compiler used to |
1526 | +produce the work, or an object code interpreter used to run it. |
1527 | + |
1528 | + The "Corresponding Source" for a work in object code form means all |
1529 | +the source code needed to generate, install, and (for an executable |
1530 | +work) run the object code and to modify the work, including scripts to |
1531 | +control those activities. However, it does not include the work's |
1532 | +System Libraries, or general-purpose tools or generally available free |
1533 | +programs which are used unmodified in performing those activities but |
1534 | +which are not part of the work. For example, Corresponding Source |
1535 | +includes interface definition files associated with source files for |
1536 | +the work, and the source code for shared libraries and dynamically |
1537 | +linked subprograms that the work is specifically designed to require, |
1538 | +such as by intimate data communication or control flow between those |
1539 | +subprograms and other parts of the work. |
1540 | + |
1541 | + The Corresponding Source need not include anything that users |
1542 | +can regenerate automatically from other parts of the Corresponding |
1543 | +Source. |
1544 | + |
1545 | + The Corresponding Source for a work in source code form is that |
1546 | +same work. |
1547 | + |
1548 | + 2. Basic Permissions. |
1549 | + |
1550 | + All rights granted under this License are granted for the term of |
1551 | +copyright on the Program, and are irrevocable provided the stated |
1552 | +conditions are met. This License explicitly affirms your unlimited |
1553 | +permission to run the unmodified Program. The output from running a |
1554 | +covered work is covered by this License only if the output, given its |
1555 | +content, constitutes a covered work. This License acknowledges your |
1556 | +rights of fair use or other equivalent, as provided by copyright law. |
1557 | + |
1558 | + You may make, run and propagate covered works that you do not |
1559 | +convey, without conditions so long as your license otherwise remains |
1560 | +in force. You may convey covered works to others for the sole purpose |
1561 | +of having them make modifications exclusively for you, or provide you |
1562 | +with facilities for running those works, provided that you comply with |
1563 | +the terms of this License in conveying all material for which you do |
1564 | +not control copyright. Those thus making or running the covered works |
1565 | +for you must do so exclusively on your behalf, under your direction |
1566 | +and control, on terms that prohibit them from making any copies of |
1567 | +your copyrighted material outside their relationship with you. |
1568 | + |
1569 | + Conveying under any other circumstances is permitted solely under |
1570 | +the conditions stated below. Sublicensing is not allowed; section 10 |
1571 | +makes it unnecessary. |
1572 | + |
1573 | + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
1574 | + |
1575 | + No covered work shall be deemed part of an effective technological |
1576 | +measure under any applicable law fulfilling obligations under article |
1577 | +11 of the WIPO copyright treaty adopted on 20 December 1996, or |
1578 | +similar laws prohibiting or restricting circumvention of such |
1579 | +measures. |
1580 | + |
1581 | + When you convey a covered work, you waive any legal power to forbid |
1582 | +circumvention of technological measures to the extent such circumvention |
1583 | +is effected by exercising rights under this License with respect to |
1584 | +the covered work, and you disclaim any intention to limit operation or |
1585 | +modification of the work as a means of enforcing, against the work's |
1586 | +users, your or third parties' legal rights to forbid circumvention of |
1587 | +technological measures. |
1588 | + |
1589 | + 4. Conveying Verbatim Copies. |
1590 | + |
1591 | + You may convey verbatim copies of the Program's source code as you |
1592 | +receive it, in any medium, provided that you conspicuously and |
1593 | +appropriately publish on each copy an appropriate copyright notice; |
1594 | +keep intact all notices stating that this License and any |
1595 | +non-permissive terms added in accord with section 7 apply to the code; |
1596 | +keep intact all notices of the absence of any warranty; and give all |
1597 | +recipients a copy of this License along with the Program. |
1598 | + |
1599 | + You may charge any price or no price for each copy that you convey, |
1600 | +and you may offer support or warranty protection for a fee. |
1601 | + |
1602 | + 5. Conveying Modified Source Versions. |
1603 | + |
1604 | + You may convey a work based on the Program, or the modifications to |
1605 | +produce it from the Program, in the form of source code under the |
1606 | +terms of section 4, provided that you also meet all of these conditions: |
1607 | + |
1608 | + a) The work must carry prominent notices stating that you modified |
1609 | + it, and giving a relevant date. |
1610 | + |
1611 | + b) The work must carry prominent notices stating that it is |
1612 | + released under this License and any conditions added under section |
1613 | + 7. This requirement modifies the requirement in section 4 to |
1614 | + "keep intact all notices". |
1615 | + |
1616 | + c) You must license the entire work, as a whole, under this |
1617 | + License to anyone who comes into possession of a copy. This |
1618 | + License will therefore apply, along with any applicable section 7 |
1619 | + additional terms, to the whole of the work, and all its parts, |
1620 | + regardless of how they are packaged. This License gives no |
1621 | + permission to license the work in any other way, but it does not |
1622 | + invalidate such permission if you have separately received it. |
1623 | + |
1624 | + d) If the work has interactive user interfaces, each must display |
1625 | + Appropriate Legal Notices; however, if the Program has interactive |
1626 | + interfaces that do not display Appropriate Legal Notices, your |
1627 | + work need not make them do so. |
1628 | + |
1629 | + A compilation of a covered work with other separate and independent |
1630 | +works, which are not by their nature extensions of the covered work, |
1631 | +and which are not combined with it such as to form a larger program, |
1632 | +in or on a volume of a storage or distribution medium, is called an |
1633 | +"aggregate" if the compilation and its resulting copyright are not |
1634 | +used to limit the access or legal rights of the compilation's users |
1635 | +beyond what the individual works permit. Inclusion of a covered work |
1636 | +in an aggregate does not cause this License to apply to the other |
1637 | +parts of the aggregate. |
1638 | + |
1639 | + 6. Conveying Non-Source Forms. |
1640 | + |
1641 | + You may convey a covered work in object code form under the terms |
1642 | +of sections 4 and 5, provided that you also convey the |
1643 | +machine-readable Corresponding Source under the terms of this License, |
1644 | +in one of these ways: |
1645 | + |
1646 | + a) Convey the object code in, or embodied in, a physical product |
1647 | + (including a physical distribution medium), accompanied by the |
1648 | + Corresponding Source fixed on a durable physical medium |
1649 | + customarily used for software interchange. |
1650 | + |
1651 | + b) Convey the object code in, or embodied in, a physical product |
1652 | + (including a physical distribution medium), accompanied by a |
1653 | + written offer, valid for at least three years and valid for as |
1654 | + long as you offer spare parts or customer support for that product |
1655 | + model, to give anyone who possesses the object code either (1) a |
1656 | + copy of the Corresponding Source for all the software in the |
1657 | + product that is covered by this License, on a durable physical |
1658 | + medium customarily used for software interchange, for a price no |
1659 | + more than your reasonable cost of physically performing this |
1660 | + conveying of source, or (2) access to copy the |
1661 | + Corresponding Source from a network server at no charge. |
1662 | + |
1663 | + c) Convey individual copies of the object code with a copy of the |
1664 | + written offer to provide the Corresponding Source. This |
1665 | + alternative is allowed only occasionally and noncommercially, and |
1666 | + only if you received the object code with such an offer, in accord |
1667 | + with subsection 6b. |
1668 | + |
1669 | + d) Convey the object code by offering access from a designated |
1670 | + place (gratis or for a charge), and offer equivalent access to the |
1671 | + Corresponding Source in the same way through the same place at no |
1672 | + further charge. You need not require recipients to copy the |
1673 | + Corresponding Source along with the object code. If the place to |
1674 | + copy the object code is a network server, the Corresponding Source |
1675 | + may be on a different server (operated by you or a third party) |
1676 | + that supports equivalent copying facilities, provided you maintain |
1677 | + clear directions next to the object code saying where to find the |
1678 | + Corresponding Source. Regardless of what server hosts the |
1679 | + Corresponding Source, you remain obligated to ensure that it is |
1680 | + available for as long as needed to satisfy these requirements. |
1681 | + |
1682 | + e) Convey the object code using peer-to-peer transmission, provided |
1683 | + you inform other peers where the object code and Corresponding |
1684 | + Source of the work are being offered to the general public at no |
1685 | + charge under subsection 6d. |
1686 | + |
1687 | + A separable portion of the object code, whose source code is excluded |
1688 | +from the Corresponding Source as a System Library, need not be |
1689 | +included in conveying the object code work. |
1690 | + |
1691 | + A "User Product" is either (1) a "consumer product", which means any |
1692 | +tangible personal property which is normally used for personal, family, |
1693 | +or household purposes, or (2) anything designed or sold for incorporation |
1694 | +into a dwelling. In determining whether a product is a consumer product, |
1695 | +doubtful cases shall be resolved in favor of coverage. For a particular |
1696 | +product received by a particular user, "normally used" refers to a |
1697 | +typical or common use of that class of product, regardless of the status |
1698 | +of the particular user or of the way in which the particular user |
1699 | +actually uses, or expects or is expected to use, the product. A product |
1700 | +is a consumer product regardless of whether the product has substantial |
1701 | +commercial, industrial or non-consumer uses, unless such uses represent |
1702 | +the only significant mode of use of the product. |
1703 | + |
1704 | + "Installation Information" for a User Product means any methods, |
1705 | +procedures, authorization keys, or other information required to install |
1706 | +and execute modified versions of a covered work in that User Product from |
1707 | +a modified version of its Corresponding Source. The information must |
1708 | +suffice to ensure that the continued functioning of the modified object |
1709 | +code is in no case prevented or interfered with solely because |
1710 | +modification has been made. |
1711 | + |
1712 | + If you convey an object code work under this section in, or with, or |
1713 | +specifically for use in, a User Product, and the conveying occurs as |
1714 | +part of a transaction in which the right of possession and use of the |
1715 | +User Product is transferred to the recipient in perpetuity or for a |
1716 | +fixed term (regardless of how the transaction is characterized), the |
1717 | +Corresponding Source conveyed under this section must be accompanied |
1718 | +by the Installation Information. But this requirement does not apply |
1719 | +if neither you nor any third party retains the ability to install |
1720 | +modified object code on the User Product (for example, the work has |
1721 | +been installed in ROM). |
1722 | + |
1723 | + The requirement to provide Installation Information does not include a |
1724 | +requirement to continue to provide support service, warranty, or updates |
1725 | +for a work that has been modified or installed by the recipient, or for |
1726 | +the User Product in which it has been modified or installed. Access to a |
1727 | +network may be denied when the modification itself materially and |
1728 | +adversely affects the operation of the network or violates the rules and |
1729 | +protocols for communication across the network. |
1730 | + |
1731 | + Corresponding Source conveyed, and Installation Information provided, |
1732 | +in accord with this section must be in a format that is publicly |
1733 | +documented (and with an implementation available to the public in |
1734 | +source code form), and must require no special password or key for |
1735 | +unpacking, reading or copying. |
1736 | + |
1737 | + 7. Additional Terms. |
1738 | + |
1739 | + "Additional permissions" are terms that supplement the terms of this |
1740 | +License by making exceptions from one or more of its conditions. |
1741 | +Additional permissions that are applicable to the entire Program shall |
1742 | +be treated as though they were included in this License, to the extent |
1743 | +that they are valid under applicable law. If additional permissions |
1744 | +apply only to part of the Program, that part may be used separately |
1745 | +under those permissions, but the entire Program remains governed by |
1746 | +this License without regard to the additional permissions. |
1747 | + |
1748 | + When you convey a copy of a covered work, you may at your option |
1749 | +remove any additional permissions from that copy, or from any part of |
1750 | +it. (Additional permissions may be written to require their own |
1751 | +removal in certain cases when you modify the work.) You may place |
1752 | +additional permissions on material, added by you to a covered work, |
1753 | +for which you have or can give appropriate copyright permission. |
1754 | + |
1755 | + Notwithstanding any other provision of this License, for material you |
1756 | +add to a covered work, you may (if authorized by the copyright holders of |
1757 | +that material) supplement the terms of this License with terms: |
1758 | + |
1759 | + a) Disclaiming warranty or limiting liability differently from the |
1760 | + terms of sections 15 and 16 of this License; or |
1761 | + |
1762 | + b) Requiring preservation of specified reasonable legal notices or |
1763 | + author attributions in that material or in the Appropriate Legal |
1764 | + Notices displayed by works containing it; or |
1765 | + |
1766 | + c) Prohibiting misrepresentation of the origin of that material, or |
1767 | + requiring that modified versions of such material be marked in |
1768 | + reasonable ways as different from the original version; or |
1769 | + |
1770 | + d) Limiting the use for publicity purposes of names of licensors or |
1771 | + authors of the material; or |
1772 | + |
1773 | + e) Declining to grant rights under trademark law for use of some |
1774 | + trade names, trademarks, or service marks; or |
1775 | + |
1776 | + f) Requiring indemnification of licensors and authors of that |
1777 | + material by anyone who conveys the material (or modified versions of |
1778 | + it) with contractual assumptions of liability to the recipient, for |
1779 | + any liability that these contractual assumptions directly impose on |
1780 | + those licensors and authors. |
1781 | + |
1782 | + All other non-permissive additional terms are considered "further |
1783 | +restrictions" within the meaning of section 10. If the Program as you |
1784 | +received it, or any part of it, contains a notice stating that it is |
1785 | +governed by this License along with a term that is a further |
1786 | +restriction, you may remove that term. If a license document contains |
1787 | +a further restriction but permits relicensing or conveying under this |
1788 | +License, you may add to a covered work material governed by the terms |
1789 | +of that license document, provided that the further restriction does |
1790 | +not survive such relicensing or conveying. |
1791 | + |
1792 | + If you add terms to a covered work in accord with this section, you |
1793 | +must place, in the relevant source files, a statement of the |
1794 | +additional terms that apply to those files, or a notice indicating |
1795 | +where to find the applicable terms. |
1796 | + |
1797 | + Additional terms, permissive or non-permissive, may be stated in the |
1798 | +form of a separately written license, or stated as exceptions; |
1799 | +the above requirements apply either way. |
1800 | + |
1801 | + 8. Termination. |
1802 | + |
1803 | + You may not propagate or modify a covered work except as expressly |
1804 | +provided under this License. Any attempt otherwise to propagate or |
1805 | +modify it is void, and will automatically terminate your rights under |
1806 | +this License (including any patent licenses granted under the third |
1807 | +paragraph of section 11). |
1808 | + |
1809 | + However, if you cease all violation of this License, then your |
1810 | +license from a particular copyright holder is reinstated (a) |
1811 | +provisionally, unless and until the copyright holder explicitly and |
1812 | +finally terminates your license, and (b) permanently, if the copyright |
1813 | +holder fails to notify you of the violation by some reasonable means |
1814 | +prior to 60 days after the cessation. |
1815 | + |
1816 | + Moreover, your license from a particular copyright holder is |
1817 | +reinstated permanently if the copyright holder notifies you of the |
1818 | +violation by some reasonable means, this is the first time you have |
1819 | +received notice of violation of this License (for any work) from that |
1820 | +copyright holder, and you cure the violation prior to 30 days after |
1821 | +your receipt of the notice. |
1822 | + |
1823 | + Termination of your rights under this section does not terminate the |
1824 | +licenses of parties who have received copies or rights from you under |
1825 | +this License. If your rights have been terminated and not permanently |
1826 | +reinstated, you do not qualify to receive new licenses for the same |
1827 | +material under section 10. |
1828 | + |
1829 | + 9. Acceptance Not Required for Having Copies. |
1830 | + |
1831 | + You are not required to accept this License in order to receive or |
1832 | +run a copy of the Program. Ancillary propagation of a covered work |
1833 | +occurring solely as a consequence of using peer-to-peer transmission |
1834 | +to receive a copy likewise does not require acceptance. However, |
1835 | +nothing other than this License grants you permission to propagate or |
1836 | +modify any covered work. These actions infringe copyright if you do |
1837 | +not accept this License. Therefore, by modifying or propagating a |
1838 | +covered work, you indicate your acceptance of this License to do so. |
1839 | + |
1840 | + 10. Automatic Licensing of Downstream Recipients. |
1841 | + |
1842 | + Each time you convey a covered work, the recipient automatically |
1843 | +receives a license from the original licensors, to run, modify and |
1844 | +propagate that work, subject to this License. You are not responsible |
1845 | +for enforcing compliance by third parties with this License. |
1846 | + |
1847 | + An "entity transaction" is a transaction transferring control of an |
1848 | +organization, or substantially all assets of one, or subdividing an |
1849 | +organization, or merging organizations. If propagation of a covered |
1850 | +work results from an entity transaction, each party to that |
1851 | +transaction who receives a copy of the work also receives whatever |
1852 | +licenses to the work the party's predecessor in interest had or could |
1853 | +give under the previous paragraph, plus a right to possession of the |
1854 | +Corresponding Source of the work from the predecessor in interest, if |
1855 | +the predecessor has it or can get it with reasonable efforts. |
1856 | + |
1857 | + You may not impose any further restrictions on the exercise of the |
1858 | +rights granted or affirmed under this License. For example, you may |
1859 | +not impose a license fee, royalty, or other charge for exercise of |
1860 | +rights granted under this License, and you may not initiate litigation |
1861 | +(including a cross-claim or counterclaim in a lawsuit) alleging that |
1862 | +any patent claim is infringed by making, using, selling, offering for |
1863 | +sale, or importing the Program or any portion of it. |
1864 | + |
1865 | + 11. Patents. |
1866 | + |
1867 | + A "contributor" is a copyright holder who authorizes use under this |
1868 | +License of the Program or a work on which the Program is based. The |
1869 | +work thus licensed is called the contributor's "contributor version". |
1870 | + |
1871 | + A contributor's "essential patent claims" are all patent claims |
1872 | +owned or controlled by the contributor, whether already acquired or |
1873 | +hereafter acquired, that would be infringed by some manner, permitted |
1874 | +by this License, of making, using, or selling its contributor version, |
1875 | +but do not include claims that would be infringed only as a |
1876 | +consequence of further modification of the contributor version. For |
1877 | +purposes of this definition, "control" includes the right to grant |
1878 | +patent sublicenses in a manner consistent with the requirements of |
1879 | +this License. |
1880 | + |
1881 | + Each contributor grants you a non-exclusive, worldwide, royalty-free |
1882 | +patent license under the contributor's essential patent claims, to |
1883 | +make, use, sell, offer for sale, import and otherwise run, modify and |
1884 | +propagate the contents of its contributor version. |
1885 | + |
1886 | + In the following three paragraphs, a "patent license" is any express |
1887 | +agreement or commitment, however denominated, not to enforce a patent |
1888 | +(such as an express permission to practice a patent or covenant not to |
1889 | +sue for patent infringement). To "grant" such a patent license to a |
1890 | +party means to make such an agreement or commitment not to enforce a |
1891 | +patent against the party. |
1892 | + |
1893 | + If you convey a covered work, knowingly relying on a patent license, |
1894 | +and the Corresponding Source of the work is not available for anyone |
1895 | +to copy, free of charge and under the terms of this License, through a |
1896 | +publicly available network server or other readily accessible means, |
1897 | +then you must either (1) cause the Corresponding Source to be so |
1898 | +available, or (2) arrange to deprive yourself of the benefit of the |
1899 | +patent license for this particular work, or (3) arrange, in a manner |
1900 | +consistent with the requirements of this License, to extend the patent |
1901 | +license to downstream recipients. "Knowingly relying" means you have |
1902 | +actual knowledge that, but for the patent license, your conveying the |
1903 | +covered work in a country, or your recipient's use of the covered work |
1904 | +in a country, would infringe one or more identifiable patents in that |
1905 | +country that you have reason to believe are valid. |
1906 | + |
1907 | + If, pursuant to or in connection with a single transaction or |
1908 | +arrangement, you convey, or propagate by procuring conveyance of, a |
1909 | +covered work, and grant a patent license to some of the parties |
1910 | +receiving the covered work authorizing them to use, propagate, modify |
1911 | +or convey a specific copy of the covered work, then the patent license |
1912 | +you grant is automatically extended to all recipients of the covered |
1913 | +work and works based on it. |
1914 | + |
1915 | + A patent license is "discriminatory" if it does not include within |
1916 | +the scope of its coverage, prohibits the exercise of, or is |
1917 | +conditioned on the non-exercise of one or more of the rights that are |
1918 | +specifically granted under this License. You may not convey a covered |
1919 | +work if you are a party to an arrangement with a third party that is |
1920 | +in the business of distributing software, under which you make payment |
1921 | +to the third party based on the extent of your activity of conveying |
1922 | +the work, and under which the third party grants, to any of the |
1923 | +parties who would receive the covered work from you, a discriminatory |
1924 | +patent license (a) in connection with copies of the covered work |
1925 | +conveyed by you (or copies made from those copies), or (b) primarily |
1926 | +for and in connection with specific products or compilations that |
1927 | +contain the covered work, unless you entered into that arrangement, |
1928 | +or that patent license was granted, prior to 28 March 2007. |
1929 | + |
1930 | + Nothing in this License shall be construed as excluding or limiting |
1931 | +any implied license or other defenses to infringement that may |
1932 | +otherwise be available to you under applicable patent law. |
1933 | + |
1934 | + 12. No Surrender of Others' Freedom. |
1935 | + |
1936 | + If conditions are imposed on you (whether by court order, agreement or |
1937 | +otherwise) that contradict the conditions of this License, they do not |
1938 | +excuse you from the conditions of this License. If you cannot convey a |
1939 | +covered work so as to satisfy simultaneously your obligations under this |
1940 | +License and any other pertinent obligations, then as a consequence you may |
1941 | +not convey it at all. For example, if you agree to terms that obligate you |
1942 | +to collect a royalty for further conveying from those to whom you convey |
1943 | +the Program, the only way you could satisfy both those terms and this |
1944 | +License would be to refrain entirely from conveying the Program. |
1945 | + |
1946 | + 13. Use with the GNU Affero General Public License. |
1947 | + |
1948 | + Notwithstanding any other provision of this License, you have |
1949 | +permission to link or combine any covered work with a work licensed |
1950 | +under version 3 of the GNU Affero General Public License into a single |
1951 | +combined work, and to convey the resulting work. The terms of this |
1952 | +License will continue to apply to the part which is the covered work, |
1953 | +but the special requirements of the GNU Affero General Public License, |
1954 | +section 13, concerning interaction through a network will apply to the |
1955 | +combination as such. |
1956 | + |
1957 | + 14. Revised Versions of this License. |
1958 | + |
1959 | + The Free Software Foundation may publish revised and/or new versions of |
1960 | +the GNU General Public License from time to time. Such new versions will |
1961 | +be similar in spirit to the present version, but may differ in detail to |
1962 | +address new problems or concerns. |
1963 | + |
1964 | + Each version is given a distinguishing version number. If the |
1965 | +Program specifies that a certain numbered version of the GNU General |
1966 | +Public License "or any later version" applies to it, you have the |
1967 | +option of following the terms and conditions either of that numbered |
1968 | +version or of any later version published by the Free Software |
1969 | +Foundation. If the Program does not specify a version number of the |
1970 | +GNU General Public License, you may choose any version ever published |
1971 | +by the Free Software Foundation. |
1972 | + |
1973 | + If the Program specifies that a proxy can decide which future |
1974 | +versions of the GNU General Public License can be used, that proxy's |
1975 | +public statement of acceptance of a version permanently authorizes you |
1976 | +to choose that version for the Program. |
1977 | + |
1978 | + Later license versions may give you additional or different |
1979 | +permissions. However, no additional obligations are imposed on any |
1980 | +author or copyright holder as a result of your choosing to follow a |
1981 | +later version. |
1982 | + |
1983 | + 15. Disclaimer of Warranty. |
1984 | + |
1985 | + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
1986 | +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
1987 | +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
1988 | +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
1989 | +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
1990 | +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
1991 | +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
1992 | +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
1993 | + |
1994 | + 16. Limitation of Liability. |
1995 | + |
1996 | + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
1997 | +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
1998 | +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
1999 | +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
2000 | +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
2001 | +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
2002 | +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
2003 | +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
2004 | +SUCH DAMAGES. |
2005 | + |
2006 | + 17. Interpretation of Sections 15 and 16. |
2007 | + |
2008 | + If the disclaimer of warranty and limitation of liability provided |
2009 | +above cannot be given local legal effect according to their terms, |
2010 | +reviewing courts shall apply local law that most closely approximates |
2011 | +an absolute waiver of all civil liability in connection with the |
2012 | +Program, unless a warranty or assumption of liability accompanies a |
2013 | +copy of the Program in return for a fee. |
2014 | + |
2015 | + END OF TERMS AND CONDITIONS |
2016 | + |
2017 | + How to Apply These Terms to Your New Programs |
2018 | + |
2019 | + If you develop a new program, and you want it to be of the greatest |
2020 | +possible use to the public, the best way to achieve this is to make it |
2021 | +free software which everyone can redistribute and change under these terms. |
2022 | + |
2023 | + To do so, attach the following notices to the program. It is safest |
2024 | +to attach them to the start of each source file to most effectively |
2025 | +state the exclusion of warranty; and each file should have at least |
2026 | +the "copyright" line and a pointer to where the full notice is found. |
2027 | + |
2028 | + <one line to give the program's name and a brief idea of what it does.> |
2029 | + Copyright (C) <year> <name of author> |
2030 | + |
2031 | + This program is free software: you can redistribute it and/or modify |
2032 | + it under the terms of the GNU General Public License as published by |
2033 | + the Free Software Foundation, either version 3 of the License, or |
2034 | + (at your option) any later version. |
2035 | + |
2036 | + This program is distributed in the hope that it will be useful, |
2037 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
2038 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2039 | + GNU General Public License for more details. |
2040 | + |
2041 | + You should have received a copy of the GNU General Public License |
2042 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
2043 | + |
2044 | +Also add information on how to contact you by electronic and paper mail. |
2045 | + |
2046 | + If the program does terminal interaction, make it output a short |
2047 | +notice like this when it starts in an interactive mode: |
2048 | + |
2049 | + <program> Copyright (C) <year> <name of author> |
2050 | + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
2051 | + This is free software, and you are welcome to redistribute it |
2052 | + under certain conditions; type `show c' for details. |
2053 | + |
2054 | +The hypothetical commands `show w' and `show c' should show the appropriate |
2055 | +parts of the General Public License. Of course, your program's commands |
2056 | +might be different; for a GUI interface, you would use an "about box". |
2057 | + |
2058 | + You should also get your employer (if you work as a programmer) or school, |
2059 | +if any, to sign a "copyright disclaimer" for the program, if necessary. |
2060 | +For more information on this, and how to apply and follow the GNU GPL, see |
2061 | +<http://www.gnu.org/licenses/>. |
2062 | + |
2063 | + The GNU General Public License does not permit incorporating your program |
2064 | +into proprietary programs. If your program is a subroutine library, you |
2065 | +may consider it more useful to permit linking proprietary applications with |
2066 | +the library. If this is what you want to do, use the GNU Lesser General |
2067 | +Public License instead of this License. But first, please read |
2068 | +<http://www.gnu.org/philosophy/why-not-lgpl.html>. |
2069 | + |
2070 | |
2071 | === added file 'doc/COPYING.LESSER' |
2072 | --- doc/COPYING.LESSER 1970-01-01 00:00:00 +0000 |
2073 | +++ doc/COPYING.LESSER 2010-07-28 20:35:51 +0000 |
2074 | @@ -0,0 +1,165 @@ |
2075 | + GNU LESSER GENERAL PUBLIC LICENSE |
2076 | + Version 3, 29 June 2007 |
2077 | + |
2078 | + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
2079 | + Everyone is permitted to copy and distribute verbatim copies |
2080 | + of this license document, but changing it is not allowed. |
2081 | + |
2082 | + |
2083 | + This version of the GNU Lesser General Public License incorporates |
2084 | +the terms and conditions of version 3 of the GNU General Public |
2085 | +License, supplemented by the additional permissions listed below. |
2086 | + |
2087 | + 0. Additional Definitions. |
2088 | + |
2089 | + As used herein, "this License" refers to version 3 of the GNU Lesser |
2090 | +General Public License, and the "GNU GPL" refers to version 3 of the GNU |
2091 | +General Public License. |
2092 | + |
2093 | + "The Library" refers to a covered work governed by this License, |
2094 | +other than an Application or a Combined Work as defined below. |
2095 | + |
2096 | + An "Application" is any work that makes use of an interface provided |
2097 | +by the Library, but which is not otherwise based on the Library. |
2098 | +Defining a subclass of a class defined by the Library is deemed a mode |
2099 | +of using an interface provided by the Library. |
2100 | + |
2101 | + A "Combined Work" is a work produced by combining or linking an |
2102 | +Application with the Library. The particular version of the Library |
2103 | +with which the Combined Work was made is also called the "Linked |
2104 | +Version". |
2105 | + |
2106 | + The "Minimal Corresponding Source" for a Combined Work means the |
2107 | +Corresponding Source for the Combined Work, excluding any source code |
2108 | +for portions of the Combined Work that, considered in isolation, are |
2109 | +based on the Application, and not on the Linked Version. |
2110 | + |
2111 | + The "Corresponding Application Code" for a Combined Work means the |
2112 | +object code and/or source code for the Application, including any data |
2113 | +and utility programs needed for reproducing the Combined Work from the |
2114 | +Application, but excluding the System Libraries of the Combined Work. |
2115 | + |
2116 | + 1. Exception to Section 3 of the GNU GPL. |
2117 | + |
2118 | + You may convey a covered work under sections 3 and 4 of this License |
2119 | +without being bound by section 3 of the GNU GPL. |
2120 | + |
2121 | + 2. Conveying Modified Versions. |
2122 | + |
2123 | + If you modify a copy of the Library, and, in your modifications, a |
2124 | +facility refers to a function or data to be supplied by an Application |
2125 | +that uses the facility (other than as an argument passed when the |
2126 | +facility is invoked), then you may convey a copy of the modified |
2127 | +version: |
2128 | + |
2129 | + a) under this License, provided that you make a good faith effort to |
2130 | + ensure that, in the event an Application does not supply the |
2131 | + function or data, the facility still operates, and performs |
2132 | + whatever part of its purpose remains meaningful, or |
2133 | + |
2134 | + b) under the GNU GPL, with none of the additional permissions of |
2135 | + this License applicable to that copy. |
2136 | + |
2137 | + 3. Object Code Incorporating Material from Library Header Files. |
2138 | + |
2139 | + The object code form of an Application may incorporate material from |
2140 | +a header file that is part of the Library. You may convey such object |
2141 | +code under terms of your choice, provided that, if the incorporated |
2142 | +material is not limited to numerical parameters, data structure |
2143 | +layouts and accessors, or small macros, inline functions and templates |
2144 | +(ten or fewer lines in length), you do both of the following: |
2145 | + |
2146 | + a) Give prominent notice with each copy of the object code that the |
2147 | + Library is used in it and that the Library and its use are |
2148 | + covered by this License. |
2149 | + |
2150 | + b) Accompany the object code with a copy of the GNU GPL and this license |
2151 | + document. |
2152 | + |
2153 | + 4. Combined Works. |
2154 | + |
2155 | + You may convey a Combined Work under terms of your choice that, |
2156 | +taken together, effectively do not restrict modification of the |
2157 | +portions of the Library contained in the Combined Work and reverse |
2158 | +engineering for debugging such modifications, if you also do each of |
2159 | +the following: |
2160 | + |
2161 | + a) Give prominent notice with each copy of the Combined Work that |
2162 | + the Library is used in it and that the Library and its use are |
2163 | + covered by this License. |
2164 | + |
2165 | + b) Accompany the Combined Work with a copy of the GNU GPL and this license |
2166 | + document. |
2167 | + |
2168 | + c) For a Combined Work that displays copyright notices during |
2169 | + execution, include the copyright notice for the Library among |
2170 | + these notices, as well as a reference directing the user to the |
2171 | + copies of the GNU GPL and this license document. |
2172 | + |
2173 | + d) Do one of the following: |
2174 | + |
2175 | + 0) Convey the Minimal Corresponding Source under the terms of this |
2176 | + License, and the Corresponding Application Code in a form |
2177 | + suitable for, and under terms that permit, the user to |
2178 | + recombine or relink the Application with a modified version of |
2179 | + the Linked Version to produce a modified Combined Work, in the |
2180 | + manner specified by section 6 of the GNU GPL for conveying |
2181 | + Corresponding Source. |
2182 | + |
2183 | + 1) Use a suitable shared library mechanism for linking with the |
2184 | + Library. A suitable mechanism is one that (a) uses at run time |
2185 | + a copy of the Library already present on the user's computer |
2186 | + system, and (b) will operate properly with a modified version |
2187 | + of the Library that is interface-compatible with the Linked |
2188 | + Version. |
2189 | + |
2190 | + e) Provide Installation Information, but only if you would otherwise |
2191 | + be required to provide such information under section 6 of the |
2192 | + GNU GPL, and only to the extent that such information is |
2193 | + necessary to install and execute a modified version of the |
2194 | + Combined Work produced by recombining or relinking the |
2195 | + Application with a modified version of the Linked Version. (If |
2196 | + you use option 4d0, the Installation Information must accompany |
2197 | + the Minimal Corresponding Source and Corresponding Application |
2198 | + Code. If you use option 4d1, you must provide the Installation |
2199 | + Information in the manner specified by section 6 of the GNU GPL |
2200 | + for conveying Corresponding Source.) |
2201 | + |
2202 | + 5. Combined Libraries. |
2203 | + |
2204 | + You may place library facilities that are a work based on the |
2205 | +Library side by side in a single library together with other library |
2206 | +facilities that are not Applications and are not covered by this |
2207 | +License, and convey such a combined library under terms of your |
2208 | +choice, if you do both of the following: |
2209 | + |
2210 | + a) Accompany the combined library with a copy of the same work based |
2211 | + on the Library, uncombined with any other library facilities, |
2212 | + conveyed under the terms of this License. |
2213 | + |
2214 | + b) Give prominent notice with the combined library that part of it |
2215 | + is a work based on the Library, and explaining where to find the |
2216 | + accompanying uncombined form of the same work. |
2217 | + |
2218 | + 6. Revised Versions of the GNU Lesser General Public License. |
2219 | + |
2220 | + The Free Software Foundation may publish revised and/or new versions |
2221 | +of the GNU Lesser General Public License from time to time. Such new |
2222 | +versions will be similar in spirit to the present version, but may |
2223 | +differ in detail to address new problems or concerns. |
2224 | + |
2225 | + Each version is given a distinguishing version number. If the |
2226 | +Library as you received it specifies that a certain numbered version |
2227 | +of the GNU Lesser General Public License "or any later version" |
2228 | +applies to it, you have the option of following the terms and |
2229 | +conditions either of that published version or of any later version |
2230 | +published by the Free Software Foundation. If the Library as you |
2231 | +received it does not specify a version number of the GNU Lesser |
2232 | +General Public License, you may choose any version of the GNU Lesser |
2233 | +General Public License ever published by the Free Software Foundation. |
2234 | + |
2235 | + If the Library as you received it specifies that a proxy can decide |
2236 | +whether future versions of the GNU Lesser General Public License shall |
2237 | +apply, that proxy's public statement of acceptance of any version is |
2238 | +permanent authorization for you to choose that version for the |
2239 | +Library. |
2240 | |
2241 | === added file 'doc/Makefile' |
2242 | --- doc/Makefile 1970-01-01 00:00:00 +0000 |
2243 | +++ doc/Makefile 2010-07-28 20:35:51 +0000 |
2244 | @@ -0,0 +1,23 @@ |
2245 | +.PHONY: help clean html text doctest |
2246 | + |
2247 | +docs: html text |
2248 | + |
2249 | +check: doctest |
2250 | + |
2251 | +help: |
2252 | + cd src && $(MAKE) $@ |
2253 | + |
2254 | +html: |
2255 | + cd src && $(MAKE) $@ |
2256 | + cp -r src/_build/html . |
2257 | + |
2258 | +text: |
2259 | + cd src && $(MAKE) $@ |
2260 | + cd src && tools/stitch_text.py index.rst _build/text > ../psycopg2.txt |
2261 | + |
2262 | +doctest: |
2263 | + cd src && $(MAKE) $@ |
2264 | + |
2265 | +clean: |
2266 | + cd src && $(MAKE) $@ |
2267 | + rm -rf html psycopg2.txt |
2268 | |
2269 | === added file 'doc/README' |
2270 | --- doc/README 1970-01-01 00:00:00 +0000 |
2271 | +++ doc/README 2010-07-28 20:35:51 +0000 |
2272 | @@ -0,0 +1,42 @@ |
2273 | +How to build psycopg documentation |
2274 | +---------------------------------- |
2275 | + |
2276 | +- Install Sphinx, maybe in a virtualenv. Tested with Sphinx 0.6.4:: |
2277 | + |
2278 | + ~$ virtualenv pd |
2279 | + New python executable in pd/bin/python |
2280 | + Installing setuptools............done. |
2281 | + ~$ cd pd |
2282 | + ~/pd$ source bin/activate |
2283 | + (pd)~/pd$ |
2284 | + |
2285 | +- Install Sphinx in the env:: |
2286 | + |
2287 | + (pd)~/pd$ easy_install sphinx |
2288 | + Searching for sphinx |
2289 | + Reading http://pypi.python.org/simple/sphinx/ |
2290 | + Reading http://sphinx.pocoo.org/ |
2291 | + Best match: Sphinx 0.6.4 |
2292 | + ... |
2293 | + Finished processing dependencies for sphinx |
2294 | + |
2295 | +- Build psycopg2 and ensure the package can be imported (it will be used for |
2296 | + reading the version number, autodocs etc.):: |
2297 | + |
2298 | + (pd)~/pd/psycopg2$ python setup.py build |
2299 | + (pd)~/pd/psycopg2$ python setup.py install |
2300 | + running install |
2301 | + ... |
2302 | + creating ~/pd/lib/python2.6/site-packages/psycopg2 |
2303 | + ... |
2304 | + |
2305 | +- Move to the ``doc`` dir and run ``make`` from there:: |
2306 | + |
2307 | + (pd)~/pd/psycopg2$ cd doc/ |
2308 | + (pd)~/pd/psycopg2/doc$ make |
2309 | + Running Sphinx v0.6.4 |
2310 | + ... |
2311 | + |
2312 | +You should have the rendered documentation in ``./html`` and the text file |
2313 | +``psycopg2.txt`` now. |
2314 | + |
2315 | |
2316 | === removed file 'doc/TODO' |
2317 | --- doc/TODO 2006-08-09 10:28:30 +0000 |
2318 | +++ doc/TODO 1970-01-01 00:00:00 +0000 |
2319 | @@ -1,33 +0,0 @@ |
2320 | -TODO list for psycopg 2 or later |
2321 | -******************************** |
2322 | - |
2323 | -Move items to the DONE section only after writing a test for the |
2324 | -implementation. Also add a note on how the item was resolved. |
2325 | -(Obviously I was joking about the test..) |
2326 | - |
2327 | -* Find a better way to compile the type-casting code instead of including it |
2328 | - in typecast.c directy. (Including is not that bad, but the need to touch |
2329 | - psycopg/typecast.c every time is bad bad bad.) |
2330 | - |
2331 | -* executemany() should _not_ take the async flag, remove it and force multiple |
2332 | - queries to be synchronous. |
2333 | - |
2334 | -* Fix all the docstrings. |
2335 | - |
2336 | -* Support the protocols API fully. |
2337 | - |
2338 | -* Unify the common code in typecast_datetime.c and typecast_mxdatetime.c. |
2339 | - |
2340 | -* Port typecasters to new-style classes. |
2341 | - |
2342 | -* Write a complete postgresql<->python encodings table. |
2343 | - |
2344 | -* Implement binary typecasters (should be easy, but it will take time.) |
2345 | - |
2346 | -DONE |
2347 | -==== |
2348 | - |
2349 | -* Convert type-casters to new-style types in Python 2.2+. |
2350 | - |
2351 | -* callproc() never worked, fix it or remove it and raise right exception. |
2352 | - [Removed callproc code, now an exception is raised.] |
2353 | |
2354 | === removed file 'doc/api-screen.css' |
2355 | --- doc/api-screen.css 2006-08-09 10:28:30 +0000 |
2356 | +++ doc/api-screen.css 1970-01-01 00:00:00 +0000 |
2357 | @@ -1,138 +0,0 @@ |
2358 | -/* Based on the Epydoc "default.css" |
2359 | -** with some missing reST-related classes |
2360 | -** and Python syntax support (from SilverCity) |
2361 | -*/ |
2362 | - |
2363 | -/* Body color */ |
2364 | -body { background: #ffffff; color: #000000; } |
2365 | - |
2366 | -/* Tables */ |
2367 | -table.summary, table.details, table.index |
2368 | - { background: #e8f0f8; color: #000000; } |
2369 | -tr.summary, tr.details, tr.index |
2370 | - { background: #70b0f0; color: #000000; |
2371 | - text-align: left; font-size: 120%; } |
2372 | -tr.group { background: #c0e0f8; color: #000000; |
2373 | - text-align: left; font-size: 120%; |
2374 | - font-style: italic; } |
2375 | - |
2376 | -/* Documentation page titles */ |
2377 | -h2.module { margin-top: 0.2em; } |
2378 | -h2.class { margin-top: 0.2em; } |
2379 | - |
2380 | -/* Headings */ |
2381 | -h1.heading { font-size: +140%; font-style: italic; |
2382 | - font-weight: bold; } |
2383 | -h2.heading { font-size: +125%; font-style: italic; |
2384 | - font-weight: bold; } |
2385 | -h3.heading { font-size: +110%; font-style: italic; |
2386 | - font-weight: normal; } |
2387 | - |
2388 | -/* Base tree */ |
2389 | -pre.base-tree { font-size: 80%; margin: 0; } |
2390 | - |
2391 | -/* TOC */ |
2392 | -p.toc { margin: 0; } |
2393 | - |
2394 | -/* Details Sections */ |
2395 | -table.func-details { background: #e8f0f8; color: #000000; |
2396 | - border: 2px groove #c0d0d0; |
2397 | - padding: 0 1em 0 1em; margin: 0.4em 0 0 0; } |
2398 | -h3.func-detail { background: transparent; color: #000000; |
2399 | - margin: 0 0 1em 0; } |
2400 | - |
2401 | -table.var-details { background: #e8f0f8; color: #000000; |
2402 | - border: 2px groove #c0d0d0; |
2403 | - padding: 0 1em 0 1em; margin: 0.4em 0 0 0; } |
2404 | -h3.var-details { background: transparent; color: #000000; |
2405 | - margin: 0 0 1em 0; } |
2406 | - |
2407 | -/* Function signatures */ |
2408 | -.sig { background: transparent; color: #000000; |
2409 | - font-weight: bold; } |
2410 | -.sig-name { background: transparent; color: #006080; } |
2411 | -.sig-arg, .sig-kwarg, .sig-vararg |
2412 | - { background: transparent; color: #008060; } |
2413 | -.sig-default { background: transparent; color: #602000; } |
2414 | -.summary-sig { background: transparent; color: #000000; } |
2415 | -.summary-sig-name { background: transparent; color: #204080; } |
2416 | -.summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg |
2417 | - { background: transparent; color: #008060; } |
2418 | - |
2419 | -/* Doctest blocks */ |
2420 | -.py-src { background: transparent; color: #000000; } |
2421 | -.py-prompt { background: transparent; color: #005050; |
2422 | - font-weight: bold;} |
2423 | -.py-string { background: transparent; color: #006030; } |
2424 | -.py-comment { background: transparent; color: #003060; } |
2425 | -.py-keyword { background: transparent; color: #600000; } |
2426 | -.py-output { background: transparent; color: #404040; } |
2427 | -div.code-block, |
2428 | -pre.literal-block, |
2429 | -pre.doctestblock { background: #f4faff; color: #000000; |
2430 | - padding: .5em; margin: 1em; |
2431 | - border: 1px solid #708890; } |
2432 | -table pre.doctestblock |
2433 | - { background: #dce4ec; color: #000000; |
2434 | - padding: .5em; margin: 1em; |
2435 | - border: 1px solid #708890; } |
2436 | -div.code-block { font-family: monospace; } |
2437 | - |
2438 | -/* Variable values */ |
2439 | -pre.variable { background: #dce4ec; color: #000000; |
2440 | - padding: .5em; margin: 0; |
2441 | - border: 1px solid #708890; } |
2442 | -.variable-linewrap { background: transparent; color: #604000; } |
2443 | -.variable-ellipsis { background: transparent; color: #604000; } |
2444 | -.variable-quote { background: transparent; color: #604000; } |
2445 | -.re { background: transparent; color: #000000; } |
2446 | -.re-char { background: transparent; color: #006030; } |
2447 | -.re-op { background: transparent; color: #600000; } |
2448 | -.re-group { background: transparent; color: #003060; } |
2449 | -.re-ref { background: transparent; color: #404040; } |
2450 | - |
2451 | -/* Navigation bar */ |
2452 | -table.navbar { background: #a0c0ff; color: #0000ff; |
2453 | - border: 2px groove #c0d0d0; } |
2454 | -th.navbar { background: #a0c0ff; color: #0000ff; } |
2455 | -th.navselect { background: #70b0ff; color: #000000; } |
2456 | -.nomargin { margin: 0; } |
2457 | - |
2458 | -/* Links */ |
2459 | -a:link { background: transparent; color: #0000ff; } |
2460 | -a:visited { background: transparent; color: #204080; } |
2461 | -a.navbar:link { background: transparent; color: #0000ff; |
2462 | - text-decoration: none; } |
2463 | -a.navbar:visited { background: transparent; color: #204080; |
2464 | - text-decoration: none; } |
2465 | - |
2466 | -/* Admonitions */ |
2467 | -div.warning, |
2468 | -div.note { background-color: #c0e0f8; |
2469 | - border: thin solid black; |
2470 | - padding: 1em; |
2471 | - margin-left: 1em; |
2472 | - margin-right: 1em; } |
2473 | -div.warning .first, |
2474 | -div.note .first { font-family: sans-serif; |
2475 | - font-size: 110%; |
2476 | - margin-right: 0.5em; } |
2477 | - |
2478 | -/* Lists */ |
2479 | -ul { margin-top: 0; } |
2480 | - |
2481 | -/* Python syntax */ |
2482 | -.p_character { color: olive; } |
2483 | -.p_classname { color: blue; font-weight: bold; } |
2484 | -.p_commentblock {color: gray; font-style: italic; } |
2485 | -.p_commentline { color: green; font-style: italic; } |
2486 | -.p_default {} |
2487 | -.p_defname { color: #009999; font-weight: bold; } |
2488 | -.p_identifier { color: black; } |
2489 | -.p_number { color: #009999; } |
2490 | -.p_operator { color: black; } |
2491 | -.p_string { color: #7F007F; } |
2492 | -.p_stringeol { color: #7F007F; } |
2493 | -.p_triple { color: #7F0000; } |
2494 | -.p_tripledouble { color: #7F0000; } |
2495 | -.p_word { color: navy; font-weight: bold; } |
2496 | |
2497 | === removed file 'doc/async.txt' |
2498 | --- doc/async.txt 2006-08-09 10:28:30 +0000 |
2499 | +++ doc/async.txt 1970-01-01 00:00:00 +0000 |
2500 | @@ -1,67 +0,0 @@ |
2501 | -psycopg asynchronous API |
2502 | -************************ |
2503 | - |
2504 | -** Important: async quaeries are not enabled for 2.0 ** |
2505 | - |
2506 | -Program code can initiate an asynchronous query by passing an 'async=1' flag |
2507 | -to the .execute() method. A very simple example, from the connection to the |
2508 | -query: |
2509 | - |
2510 | - conn = psycopg.connect(database='test') |
2511 | - curs = conn.cursor() |
2512 | - curs.execute("SEECT * from test WHERE fielda > %s", (1971,), async=1) |
2513 | - |
2514 | -From then on any query on other cursors derived from the same connection is |
2515 | -doomed to fail (and raise an exception) until the original cursor (the one |
2516 | -executing the query) complete the asynchronous operation. This can happen in |
2517 | -a number of different ways: |
2518 | - |
2519 | - 1) one of the .fetchXXX() methods is called, effectively blocking untill |
2520 | - data has been sent from the backend to the client, terminating the |
2521 | - query. |
2522 | - |
2523 | - 2) .cancel() is called. This method tries to abort the current query and |
2524 | - will block until the query is aborted or fully executed. The return |
2525 | - value is True if the query was successfully aborted or False if it |
2526 | - was executed. Query result are discarded in both cases. |
2527 | - |
2528 | - 3) .execute() is called again on the same cursor (.execute() on a |
2529 | - different cursor will simply raise an exception.) This waits for the |
2530 | - complete execution of the current query, discard any data and execute |
2531 | - the new one. |
2532 | - |
2533 | -Note that calling .execute() two times in a row will not abort the former |
2534 | -query and will temporarily go to synchronous mode until the first of the two |
2535 | -queries is executed. |
2536 | - |
2537 | -Cursors now have some extra methods that make them usefull during |
2538 | -asynchronous queries: |
2539 | - |
2540 | - .fileno() |
2541 | - Returns the file descriptor associated with the current connection and |
2542 | - make possible to use a cursor in a context where a file object would be |
2543 | - expected (like in a select() call.) |
2544 | - |
2545 | - .isbusy() |
2546 | - Returns True if the backend is still processing the query or false if |
2547 | - data is ready to be fetched (by one of the .fetchXXX() methods.) |
2548 | - |
2549 | -A code snippet that shows how to use the cursor object in a select() call: |
2550 | - |
2551 | - import psycopg |
2552 | - import select |
2553 | - |
2554 | - conn = psycopg.connect(database='test') |
2555 | - curs = conn.cursor() |
2556 | - curs.execute("SEECT * from test WHERE fielda > %s", (1971,), async=1) |
2557 | - |
2558 | - # wait for input with a maximum timeout of 5 seconds |
2559 | - query_ended = False |
2560 | - while not query_ended: |
2561 | - rread, rwrite, rspec = select([cursor, another_file], [], [], 5) |
2562 | - if not cursor.isbusy(): |
2563 | - query_ended = True |
2564 | - # manage input from other sources like other_file, etc. |
2565 | - print "Query Results:" |
2566 | - for row in cursor: |
2567 | - print row |
2568 | |
2569 | === removed file 'doc/extensions.rst' |
2570 | --- doc/extensions.rst 2006-08-09 10:28:30 +0000 |
2571 | +++ doc/extensions.rst 1970-01-01 00:00:00 +0000 |
2572 | @@ -1,260 +0,0 @@ |
2573 | -======================================= |
2574 | - psycopg 2 extensions to the DBAPI 2.0 |
2575 | -======================================= |
2576 | - |
2577 | -This document is a short summary of the extensions built in psycopg 2.0.x over |
2578 | -the standard `Python Database API Specification 2.0`__, usually called simply |
2579 | -DBAPI-2.0 or even PEP-249. Before reading on this document please make sure |
2580 | -you already know how to program in Python using a DBAPI-2.0 compliant driver: |
2581 | -basic concepts like opening a connection, executing queries and commiting or |
2582 | -rolling back a transaction will not be explained but just used. |
2583 | - |
2584 | -.. __: http://www.python.org/peps/pep-0249.html |
2585 | - |
2586 | -Many objects and extension functions are defined in the `psycopg2.extensions` |
2587 | -module. |
2588 | - |
2589 | - |
2590 | -Connection and cursor factories |
2591 | -=============================== |
2592 | - |
2593 | -psycopg 2 exposes two new-style classes that can be sub-classed and expanded to |
2594 | -adapt them to the needs of the programmer: `cursor` and `connection`. The |
2595 | -`connection` class is usually sub-classed only to provide an easy way to create |
2596 | -customized cursors but other uses are possible. `cursor` is much more |
2597 | -interesting, because it is the class where query building, execution and result |
2598 | -type-casting into Python variables happens. |
2599 | - |
2600 | -An example of cursor subclass performing logging is:: |
2601 | - |
2602 | - import psycopg2 |
2603 | - import psycopg2.extensions |
2604 | - import logging |
2605 | - |
2606 | - class LoggingCursor(psycopg2.extensions.cursor): |
2607 | - def execute(self, sql, args=None): |
2608 | - logger = logging.getLogger('sql_debug') |
2609 | - logger.info(self.mogrify(sql, args)) |
2610 | - |
2611 | - try: |
2612 | - psycopg2.extensions.cursor.execute(self, sql, args) |
2613 | - except Exception, exc: |
2614 | - logger.error("%s: %s" % (exc.__class__.__name__, exc)) |
2615 | - raise |
2616 | - |
2617 | - conn = psycopg2.connect(DSN) |
2618 | - curs = conn.cursor(cursor_factory=LoggingCursor) |
2619 | - curs.execute("INSERT INTO mytable VALUES (%s, %s, %s);", |
2620 | - (10, 20, 30)) |
2621 | - |
2622 | - |
2623 | -Row factories |
2624 | -------------- |
2625 | - |
2626 | -tzinfo factories |
2627 | ----------------- |
2628 | - |
2629 | - |
2630 | -Setting transaction isolation levels |
2631 | -==================================== |
2632 | - |
2633 | -psycopg2 connection objects hold informations about the PostgreSQL `transaction |
2634 | -isolation level`_. The current transaction level can be read from the |
2635 | -`.isolation_level` attribute. The default isolation level is ``READ |
2636 | -COMMITTED``. A different isolation level con be set through the |
2637 | -`.set_isolation_level()` method. The level can be set to one of the following |
2638 | -constants, defined in `psycopg2.extensions`: |
2639 | - |
2640 | -`ISOLATION_LEVEL_AUTOCOMMIT` |
2641 | - No transaction is started when command are issued and no |
2642 | - `.commit()`/`.rollback()` is required. Some PostgreSQL command such as |
2643 | - ``CREATE DATABASE`` can't run into a transaction: to run such command use |
2644 | - `.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)`. |
2645 | - |
2646 | -`ISOLATION_LEVEL_READ_COMMITTED` |
2647 | - This is the default value. A new transaction is started at the first |
2648 | - `.execute()` command on a cursor and at each new `.execute()` after a |
2649 | - `.commit()` or a `.rollback()`. The transaction runs in the PostgreSQL |
2650 | - ``READ COMMITTED`` isolation level. |
2651 | - |
2652 | -`ISOLATION_LEVEL_SERIALIZABLE` |
2653 | - Transactions are run at a ``SERIALIZABLE`` isolation level. |
2654 | - |
2655 | - |
2656 | -.. _transaction isolation level: |
2657 | - http://www.postgresql.org/docs/8.1/static/transaction-iso.html |
2658 | - |
2659 | - |
2660 | -Adaptation of Python values to SQL types |
2661 | -======================================== |
2662 | - |
2663 | -psycopg2 casts Python variables to SQL literals by type. Standard Python types |
2664 | -are already adapted to the proper SQL literal. |
2665 | - |
2666 | -Example: the Python function:: |
2667 | - |
2668 | - curs.execute("""INSERT INTO atable (anint, adate, astring) |
2669 | - VALUES (%s, %s, %s)""", |
2670 | - (10, datetime.date(2005, 11, 18), "O'Reilly")) |
2671 | - |
2672 | -is converted into the SQL command:: |
2673 | - |
2674 | - INSERT INTO atable (anint, adate, astring) |
2675 | - VALUES (10, '2005-11-18', 'O''Reilly'); |
2676 | - |
2677 | -Named arguments are supported too with ``%(name)s`` placeholders. Notice that: |
2678 | - |
2679 | - - The Python string operator ``%`` is not used: the `.execute()` function |
2680 | - accepts the values tuple or dictionary as second parameter. |
2681 | - |
2682 | - - The variables placeholder must always be a ``%s``, even if a different |
2683 | - placeholder (such as a ``%d`` for an integer) may look more appropriate. |
2684 | - |
2685 | - - For positional variables binding, the second argument must always be a |
2686 | - tuple, even if it contains a single variable. |
2687 | - |
2688 | - - Only variable values should be bound via this method: it shouldn't be used |
2689 | - to set table or field names. For these elements, ordinary string formatting |
2690 | - should be used before running `.execute()`. |
2691 | - |
2692 | - |
2693 | -Adapting new types |
2694 | ------------------- |
2695 | - |
2696 | -Any Python class or type can be adapted to an SQL string. Adaptation mechanism |
2697 | -is similar to the Object Adaptation proposed in the `PEP-246`_ and is exposed |
2698 | -by the `adapt()` function. |
2699 | - |
2700 | -psycopg2 `.execute()` method adapts its ``vars`` arguments to the `ISQLQuote` |
2701 | -protocol. Objects that conform to this protocol expose a ``getquoted()`` method |
2702 | -returning the SQL representation of the object as a string. |
2703 | - |
2704 | -The easiest way to adapt an object to an SQL string is to register an adapter |
2705 | -function via the `register_adapter()` function. The adapter function must take |
2706 | -the value to be adapted as argument and return a conform object. A convenient |
2707 | -object is the `AsIs` wrapper, whose ``getquoted()`` result is simply the |
2708 | -``str()``\ ingification of the wrapped object. |
2709 | - |
2710 | -Example: mapping of a ``Point`` class into the ``point`` PostgreSQL geometric |
2711 | -type:: |
2712 | - |
2713 | - from psycopg2.extensions import adapt, register_adapter, AsIs |
2714 | - |
2715 | - class Point(object): |
2716 | - def __init__(self, x=0.0, y=0.0): |
2717 | - self.x = x |
2718 | - self.y = y |
2719 | - |
2720 | - def adapt_point(point): |
2721 | - return AsIs("'(%s,%s)'" % (adapt(point.x), adapt(point.y))) |
2722 | - |
2723 | - register_adapter(Point, adapt_point) |
2724 | - |
2725 | - curs.execute("INSERT INTO atable (apoint) VALUES (%s)", |
2726 | - (Point(1.23, 4.56),)) |
2727 | - |
2728 | -The above function call results in the SQL command:: |
2729 | - |
2730 | - INSERT INTO atable (apoint) VALUES ((1.23, 4.56)); |
2731 | - |
2732 | - |
2733 | -.. _PEP-246: http://www.python.org/peps/pep-0246.html |
2734 | - |
2735 | - |
2736 | -Type casting of SQL types into Python values |
2737 | -============================================ |
2738 | - |
2739 | -PostgreSQL objects read from the database can be adapted to Python objects |
2740 | -through an user-defined adapting function. An adapter function takes two |
2741 | -argments: the object string representation as returned by PostgreSQL and the |
2742 | -cursor currently being read, and should return a new Python object. For |
2743 | -example, the following function parses a PostgreSQL ``point`` into the |
2744 | -previously defined ``Point`` class:: |
2745 | - |
2746 | - def cast_point(value, curs): |
2747 | - if value is not None: |
2748 | - # Convert from (f1, f2) syntax using a regular expression. |
2749 | - m = re.match("\((.*),(.*)\)", value) |
2750 | - if m: |
2751 | - return Point(float(m.group(1)), float(m.group(2))) |
2752 | - |
2753 | -To create a mapping from the PostgreSQL type (either standard or user-defined), |
2754 | -its ``oid`` must be known. It can be retrieved either by the second column of |
2755 | -the cursor description:: |
2756 | - |
2757 | - curs.execute("SELECT NULL::point") |
2758 | - point_oid = curs.description[0][1] # usually returns 600 |
2759 | - |
2760 | -or by querying the system catalogs for the type name and namespace (the |
2761 | -namespace for system objects is ``pg_catalog``):: |
2762 | - |
2763 | - curs.execute(""" |
2764 | - SELECT pg_type.oid |
2765 | - FROM pg_type JOIN pg_namespace |
2766 | - ON typnamespace = pg_namespace.oid |
2767 | - WHERE typname = %(typename)s |
2768 | - AND nspname = %(namespace)s""", |
2769 | - {'typename': 'point', 'namespace': 'pg_catalog'}) |
2770 | - |
2771 | - point_oid = curs.fetchone()[0] |
2772 | - |
2773 | -After you know the object ``oid``, you must can and register the new type:: |
2774 | - |
2775 | - POINT = psycopg2.extensions.new_type((point_oid,), "POINT", cast_point) |
2776 | - psycopg2.extensions.register_type(POINT) |
2777 | - |
2778 | -The `new_type()` function binds the object oids (more than one can be |
2779 | -specified) to the adapter function. `register_type()` completes the spell. |
2780 | -Conversion is automatically performed when a column whose type is a registered |
2781 | -``oid`` is read:: |
2782 | - |
2783 | - curs.execute("SELECT '(10.2,20.3)'::point") |
2784 | - point = curs.fetchone()[0] |
2785 | - print type(point), point.x, point.y |
2786 | - # Prints: "<class '__main__.Point'> 10.2 20.3" |
2787 | - |
2788 | - |
2789 | -Working with times and dates |
2790 | -============================ |
2791 | - |
2792 | - |
2793 | -Receiving NOTIFYs |
2794 | -================= |
2795 | - |
2796 | - |
2797 | -Using COPY TO and COPY FROM |
2798 | -=========================== |
2799 | - |
2800 | -psycopg2 `cursor` object provides an interface to the efficient `PostgreSQL |
2801 | -COPY command`__ to move data from files to tables and back. |
2802 | - |
2803 | -The `.copy_to(file, table)` method writes the content of the table |
2804 | -named ``table`` *to* the file-like object ``file``. ``file`` must have a |
2805 | -``write()`` method. |
2806 | - |
2807 | -The `.copy_from(file, table)` reads data *from* the file-like object |
2808 | -``file`` appending them to the table named ``table``. ``file`` must have both |
2809 | -``read()`` and ``readline()`` method. |
2810 | - |
2811 | -Both methods accept two optional arguments: ``sep`` (defaulting to a tab) is |
2812 | -the columns separator and ``null`` (defaulting to ``\N``) represents ``NULL`` |
2813 | -values in the file. |
2814 | - |
2815 | -.. __: http://www.postgresql.org/docs/8.1/static/sql-copy.html |
2816 | - |
2817 | - |
2818 | -PostgreSQL status message and executed query |
2819 | -============================================ |
2820 | - |
2821 | -`cursor` objects have two special fields related to the last executed query: |
2822 | - |
2823 | - - `.query` is the textual representation (str or unicode, depending on what |
2824 | - was passed to `.execute()` as first argument) of the query *after* argument |
2825 | - binding and mogrification has been applied. To put it another way, `.query` |
2826 | - is the *exact* query that was sent to the PostgreSQL backend. |
2827 | - |
2828 | - - `.statusmessage` is the status message that the backend sent upon query |
2829 | - execution. It usually contains the basic type of the query (SELECT, |
2830 | - INSERT, UPDATE, ...) and some additional information like the number of |
2831 | - rows updated and so on. Refer to the PostgreSQL manual for more |
2832 | - information. |
2833 | |
2834 | === added directory 'doc/html' |
2835 | === added file 'doc/html/.buildinfo' |
2836 | --- doc/html/.buildinfo 1970-01-01 00:00:00 +0000 |
2837 | +++ doc/html/.buildinfo 2010-07-28 20:35:51 +0000 |
2838 | @@ -0,0 +1,4 @@ |
2839 | +# Sphinx build info version 1 |
2840 | +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. |
2841 | +config: 3b2e5d90696feaaf51ed99c8708bfbca |
2842 | +tags: fbb0d17656682115ca4d033fb2f83ba1 |
2843 | |
2844 | === added directory 'doc/html/_sources' |
2845 | === added file 'doc/html/_sources/advanced.txt' |
2846 | --- doc/html/_sources/advanced.txt 1970-01-01 00:00:00 +0000 |
2847 | +++ doc/html/_sources/advanced.txt 2010-07-28 20:35:51 +0000 |
2848 | @@ -0,0 +1,450 @@ |
2849 | +More advanced topics |
2850 | +==================== |
2851 | + |
2852 | +.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com> |
2853 | + |
2854 | +.. testsetup:: * |
2855 | + |
2856 | + import re |
2857 | + import select |
2858 | + |
2859 | + cur.execute("CREATE TABLE atable (apoint point)") |
2860 | + conn.commit() |
2861 | + |
2862 | + def wait(conn): |
2863 | + while 1: |
2864 | + state = conn.poll() |
2865 | + if state == psycopg2.extensions.POLL_OK: |
2866 | + break |
2867 | + elif state == psycopg2.extensions.POLL_WRITE: |
2868 | + select.select([], [conn.fileno()], []) |
2869 | + elif state == psycopg2.extensions.POLL_READ: |
2870 | + select.select([conn.fileno()], [], []) |
2871 | + else: |
2872 | + raise psycopg2.OperationalError("poll() returned %s" % state) |
2873 | + |
2874 | + aconn = psycopg2.connect(database='test', async=1) |
2875 | + wait(aconn) |
2876 | + acurs = aconn.cursor() |
2877 | + |
2878 | +.. index:: |
2879 | + double: Subclassing; Cursor |
2880 | + double: Subclassing; Connection |
2881 | + |
2882 | +.. _subclassing-connection: |
2883 | +.. _subclassing-cursor: |
2884 | + |
2885 | +Connection and cursor factories |
2886 | +------------------------------- |
2887 | + |
2888 | +Psycopg exposes two new-style classes that can be sub-classed and expanded to |
2889 | +adapt them to the needs of the programmer: `psycopg2.extensions.cursor` |
2890 | +and `psycopg2.extensions.connection`. The `connection` class is |
2891 | +usually sub-classed only to provide an easy way to create customized cursors |
2892 | +but other uses are possible. `cursor` is much more interesting, because |
2893 | +it is the class where query building, execution and result type-casting into |
2894 | +Python variables happens. |
2895 | + |
2896 | +.. index:: |
2897 | + single: Example; Cursor subclass |
2898 | + |
2899 | +An example of cursor subclass performing logging is:: |
2900 | + |
2901 | + import psycopg2 |
2902 | + import psycopg2.extensions |
2903 | + import logging |
2904 | + |
2905 | + class LoggingCursor(psycopg2.extensions.cursor): |
2906 | + def execute(self, sql, args=None): |
2907 | + logger = logging.getLogger('sql_debug') |
2908 | + logger.info(self.mogrify(sql, args)) |
2909 | + |
2910 | + try: |
2911 | + psycopg2.extensions.cursor.execute(self, sql, args) |
2912 | + except Exception, exc: |
2913 | + logger.error("%s: %s" % (exc.__class__.__name__, exc)) |
2914 | + raise |
2915 | + |
2916 | + conn = psycopg2.connect(DSN) |
2917 | + cur = conn.cursor(cursor_factory=LoggingCursor) |
2918 | + cur.execute("INSERT INTO mytable VALUES (%s, %s, %s);", |
2919 | + (10, 20, 30)) |
2920 | + |
2921 | + |
2922 | + |
2923 | +.. index:: |
2924 | + single: Objects; Creating new adapters |
2925 | + single: Adaptation; Creating new adapters |
2926 | + single: Data types; Creating new adapters |
2927 | + |
2928 | +.. _adapting-new-types: |
2929 | + |
2930 | +Adapting new Python types to SQL syntax |
2931 | +--------------------------------------- |
2932 | + |
2933 | +Any Python class or type can be adapted to an SQL string. Adaptation mechanism |
2934 | +is similar to the Object Adaptation proposed in the :pep:`246` and is exposed |
2935 | +by the `psycopg2.extensions.adapt()` function. |
2936 | + |
2937 | +The `~cursor.execute()` method adapts its arguments to the |
2938 | +`~psycopg2.extensions.ISQLQuote` protocol. Objects that conform to this |
2939 | +protocol expose a `!getquoted()` method returning the SQL representation |
2940 | +of the object as a string. |
2941 | + |
2942 | +The easiest way to adapt an object to an SQL string is to register an adapter |
2943 | +function via the `~psycopg2.extensions.register_adapter()` function. The |
2944 | +adapter function must take the value to be adapted as argument and return a |
2945 | +conform object. A convenient object is the `~psycopg2.extensions.AsIs` |
2946 | +wrapper, whose `!getquoted()` result is simply the `!str()`\ ing |
2947 | +conversion of the wrapped object. |
2948 | + |
2949 | +.. index:: |
2950 | + single: Example; Types adaptation |
2951 | + |
2952 | +Example: mapping of a `!Point` class into the |point|_ PostgreSQL |
2953 | +geometric type: |
2954 | + |
2955 | +.. doctest:: |
2956 | + |
2957 | + >>> from psycopg2.extensions import adapt, register_adapter, AsIs |
2958 | + |
2959 | + >>> class Point(object): |
2960 | + ... def __init__(self, x, y): |
2961 | + ... self.x = x |
2962 | + ... self.y = y |
2963 | + |
2964 | + >>> def adapt_point(point): |
2965 | + ... return AsIs("'(%s, %s)'" % (adapt(point.x), adapt(point.y))) |
2966 | + |
2967 | + >>> register_adapter(Point, adapt_point) |
2968 | + |
2969 | + >>> cur.execute("INSERT INTO atable (apoint) VALUES (%s)", |
2970 | + ... (Point(1.23, 4.56),)) |
2971 | + |
2972 | + |
2973 | +.. |point| replace:: :sql:`point` |
2974 | +.. _point: http://www.postgresql.org/docs/8.4/static/datatype-geometric.html#AEN6084 |
2975 | + |
2976 | +The above function call results in the SQL command:: |
2977 | + |
2978 | + INSERT INTO atable (apoint) VALUES ((1.23, 4.56)); |
2979 | + |
2980 | + |
2981 | + |
2982 | +.. index:: Type casting |
2983 | + |
2984 | +.. _type-casting-from-sql-to-python: |
2985 | + |
2986 | +Type casting of SQL types into Python objects |
2987 | +--------------------------------------------- |
2988 | + |
2989 | +PostgreSQL objects read from the database can be adapted to Python objects |
2990 | +through an user-defined adapting function. An adapter function takes two |
2991 | +arguments: the object string representation as returned by PostgreSQL and the |
2992 | +cursor currently being read, and should return a new Python object. For |
2993 | +example, the following function parses the PostgreSQL :sql:`point` |
2994 | +representation into the previously defined `!Point` class: |
2995 | + |
2996 | + >>> def cast_point(value, cur): |
2997 | + ... if value is None: |
2998 | + ... return None |
2999 | + ... |
3000 | + ... # Convert from (f1, f2) syntax using a regular expression. |
3001 | + ... m = re.match(r"\(([^)]+),([^)]+)\)", value) |
3002 | + ... if m: |
3003 | + ... return Point(float(m.group(1)), float(m.group(2))) |
3004 | + ... else: |
3005 | + ... raise InterfaceError("bad point representation: %r" % value) |
3006 | + |
3007 | + |
3008 | +In order to create a mapping from a PostgreSQL type (either standard or |
3009 | +user-defined), its OID must be known. It can be retrieved either by the second |
3010 | +column of the `cursor.description`: |
3011 | + |
3012 | + >>> cur.execute("SELECT NULL::point") |
3013 | + >>> point_oid = cur.description[0][1] |
3014 | + >>> point_oid |
3015 | + 600 |
3016 | + |
3017 | +or by querying the system catalog for the type name and namespace (the |
3018 | +namespace for system objects is :sql:`pg_catalog`): |
3019 | + |
3020 | + >>> cur.execute(""" |
3021 | + ... SELECT pg_type.oid |
3022 | + ... FROM pg_type JOIN pg_namespace |
3023 | + ... ON typnamespace = pg_namespace.oid |
3024 | + ... WHERE typname = %(typename)s |
3025 | + ... AND nspname = %(namespace)s""", |
3026 | + ... {'typename': 'point', 'namespace': 'pg_catalog'}) |
3027 | + >>> point_oid = cur.fetchone()[0] |
3028 | + >>> point_oid |
3029 | + 600 |
3030 | + |
3031 | +After you know the object OID, you can create and register the new type: |
3032 | + |
3033 | + >>> POINT = psycopg2.extensions.new_type((point_oid,), "POINT", cast_point) |
3034 | + >>> psycopg2.extensions.register_type(POINT) |
3035 | + |
3036 | +The `~psycopg2.extensions.new_type()` function binds the object OIDs |
3037 | +(more than one can be specified) to the adapter function. |
3038 | +`~psycopg2.extensions.register_type()` completes the spell. Conversion |
3039 | +is automatically performed when a column whose type is a registered OID is |
3040 | +read: |
3041 | + |
3042 | + >>> cur.execute("SELECT '(10.2,20.3)'::point") |
3043 | + >>> point = cur.fetchone()[0] |
3044 | + >>> print type(point), point.x, point.y |
3045 | + <class 'Point'> 10.2 20.3 |
3046 | + |
3047 | + |
3048 | + |
3049 | +.. index:: |
3050 | + pair: Asynchronous; Notifications |
3051 | + pair: LISTEN; SQL command |
3052 | + pair: NOTIFY; SQL command |
3053 | + |
3054 | +.. _async-notify: |
3055 | + |
3056 | +Asynchronous notifications |
3057 | +-------------------------- |
3058 | + |
3059 | +Psycopg allows asynchronous interaction with other database sessions using the |
3060 | +facilities offered by PostgreSQL commands |LISTEN|_ and |NOTIFY|_. Please |
3061 | +refer to the PostgreSQL documentation for examples of how to use this form of |
3062 | +communications. |
3063 | + |
3064 | +Notifications received are made available in the `connection.notifies` |
3065 | +list. Notifications can be sent from Python code simply using a :sql:`NOTIFY` |
3066 | +command in an `~cursor.execute()` call. |
3067 | + |
3068 | +Because of the way sessions interact with notifications (see |NOTIFY|_ |
3069 | +documentation), you should keep the connection in :ref:`autocommit |
3070 | +<autocommit>` mode if you wish to receive or send notifications in a timely |
3071 | +manner. |
3072 | + |
3073 | +.. |LISTEN| replace:: :sql:`LISTEN` |
3074 | +.. _LISTEN: http://www.postgresql.org/docs/8.4/static/sql-listen.html |
3075 | +.. |NOTIFY| replace:: :sql:`NOTIFY` |
3076 | +.. _NOTIFY: http://www.postgresql.org/docs/8.4/static/sql-notify.html |
3077 | + |
3078 | +Notification are received after every query execution. If the user is interested |
3079 | +in receiving notification but not in performing any query, the |
3080 | +`~connection.poll()` method can be used to check for notification without |
3081 | +wasting resources. |
3082 | + |
3083 | +A simple application could poll the connection from time to time to check if |
3084 | +something new has arrived. A better strategy is to use some I/O completion |
3085 | +function such as |select()|_ to sleep until awaken from the kernel when there is |
3086 | +some data to read on the connection, thereby using no CPU unless there is |
3087 | +something to read:: |
3088 | + |
3089 | + import select |
3090 | + import psycopg2 |
3091 | + import psycopg2.extensions |
3092 | + |
3093 | + conn = psycopg2.connect(DSN) |
3094 | + conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) |
3095 | + |
3096 | + curs = conn.cursor() |
3097 | + curs.execute("LISTEN test;") |
3098 | + |
3099 | + print "Waiting for 'NOTIFY test'" |
3100 | + while 1: |
3101 | + if select.select([conn],[],[],5) == ([],[],[]): |
3102 | + print "Timeout" |
3103 | + else: |
3104 | + conn.poll() |
3105 | + while conn.notifies: |
3106 | + print "Got NOTIFY:", conn.notifies.pop() |
3107 | + |
3108 | +Running the script and executing the command :sql:`NOTIFY test` in a separate |
3109 | +:program:`psql` shell, the output may look similar to:: |
3110 | + |
3111 | + Waiting for 'NOTIFY test' |
3112 | + Timeout |
3113 | + Timeout |
3114 | + Got NOTIFY: (6535, 'test') |
3115 | + Timeout |
3116 | + ... |
3117 | + |
3118 | + |
3119 | + |
3120 | +.. index:: |
3121 | + double: Asynchronous; Connection |
3122 | + |
3123 | +.. _async-support: |
3124 | + |
3125 | +Asynchronous support |
3126 | +-------------------- |
3127 | + |
3128 | +.. versionadded:: 2.2.0 |
3129 | + |
3130 | +Psycopg can issue asynchronous queries to a PostgreSQL database. An asynchronous |
3131 | +communication style is established passing the parameter *async*\=1 to the |
3132 | +`~psycopg2.connect()` function: the returned connection will work in |
3133 | +*asynchronous mode*. |
3134 | + |
3135 | +In asynchronous mode, a Psycopg connection will rely on the caller to poll the |
3136 | +socket file descriptor, checking if it is ready to accept data or if a query |
3137 | +result has been transferred and is ready to be read on the client. The caller |
3138 | +can use the method `~connection.fileno()` to get the connection file |
3139 | +descriptor and `~connection.poll()` to make communication proceed according to |
3140 | +the current connection state. |
3141 | + |
3142 | +The following is an example loop using methods `!fileno()` and `!poll()` |
3143 | +together with the Python |select()|_ function in order to carry on |
3144 | +asynchronous operations with Psycopg:: |
3145 | + |
3146 | + def wait(conn): |
3147 | + while 1: |
3148 | + state = conn.poll() |
3149 | + if state == psycopg2.extensions.POLL_OK: |
3150 | + break |
3151 | + elif state == psycopg2.extensions.POLL_WRITE: |
3152 | + select.select([], [conn.fileno()], []) |
3153 | + elif state == psycopg2.extensions.POLL_READ: |
3154 | + select.select([conn.fileno()], [], []) |
3155 | + else: |
3156 | + raise psycopg2.OperationalError("poll() returned %s" % state) |
3157 | + |
3158 | +.. |select()| replace:: `!select()` |
3159 | +.. _select(): http://docs.python.org/library/select.html#select.select |
3160 | + |
3161 | +The above loop of course would block an entire application: in a real |
3162 | +asynchronous framework, `!select()` would be called on many file descriptors |
3163 | +waiting for any of them to be ready. Nonetheless the function can be used to |
3164 | +connect to a PostgreSQL server only using nonblocking commands and the |
3165 | +connection obtained can be used to perform further nonblocking queries. After |
3166 | +`!poll()` has returned `~psycopg2.extensions.POLL_OK`, and thus `!wait()` has |
3167 | +returned, the connection can be safely used: |
3168 | + |
3169 | + >>> aconn = psycopg2.connect(database='test', async=1) |
3170 | + >>> wait(aconn) |
3171 | + >>> acurs = aconn.cursor() |
3172 | + |
3173 | +Notice that there are a few other requirements to be met in order to have a |
3174 | +completely non-blocking connection attempt: see the libpq documentation for |
3175 | +|PQconnectStart|_. |
3176 | + |
3177 | +.. |PQconnectStart| replace:: `!PQconnectStart()` |
3178 | +.. _PQconnectStart: http://www.postgresql.org/docs/8.4/static/libpq-connect.html#AEN33199 |
3179 | + |
3180 | +The same loop should be also used to perform nonblocking queries: after |
3181 | +sending a query via `~cursor.execute()` or `~cursor.callproc()`, call |
3182 | +`!poll()` on the connection available from `cursor.connection` until it |
3183 | +returns `!POLL_OK`, at which pont the query has been completely sent to the |
3184 | +server and, if it produced data, the results have been transferred to the |
3185 | +client and available using the regular cursor methods: |
3186 | + |
3187 | + >>> acurs.execute("SELECT pg_sleep(5); SELECT 42;") |
3188 | + >>> wait(acurs.connection) |
3189 | + >>> acurs.fetchone()[0] |
3190 | + 42 |
3191 | + |
3192 | +When an asynchronous query is being executed, `connection.isexecuting()` returns |
3193 | +`True`. Two cursors can't execute concurrent queries on the same asynchronous |
3194 | +connection. |
3195 | + |
3196 | +There are several limitations in using asynchronous connections: the |
3197 | +connection is always in :ref:`autocommit <autocommit>` mode and it is not |
3198 | +possible to change it using `~connection.set_isolation_level()`. So a |
3199 | +transaction is not implicitly started at the first query and is not possible |
3200 | +to use methods `~connection.commit()` and `~connection.rollback()`: you can |
3201 | +manually control transactions using `~cursor.execute()` to send database |
3202 | +commands such as :sql:`BEGIN`, :sql:`COMMIT` and :sql:`ROLLBACK`. |
3203 | + |
3204 | +With asynchronous connections it is also not possible to use |
3205 | +`~connection.set_client_encoding()`, `~cursor.executemany()`, :ref:`large |
3206 | +objects <large-objects>`, :ref:`named cursors <server-side-cursors>`. |
3207 | + |
3208 | +:ref:`COPY commands <copy>` are not supported either in asynchronous mode, but |
3209 | +this will be probably implemented in a future release. |
3210 | + |
3211 | + |
3212 | + |
3213 | + |
3214 | +.. index:: |
3215 | + single: Greenlet, Coroutine, Eventlet, gevent, Wait callback |
3216 | + |
3217 | +.. _green-support: |
3218 | + |
3219 | +Support to coroutine libraries |
3220 | +------------------------------ |
3221 | + |
3222 | +.. versionadded:: 2.2.0 |
3223 | + |
3224 | +Psycopg can be used together with coroutine_\-based libraries, and participate |
3225 | +to cooperative multithreading. |
3226 | + |
3227 | +Coroutine-based libraries (such as Eventlet_ or gevent_) can usually patch the |
3228 | +Python standard library in order to enable a coroutine switch in the presence of |
3229 | +blocking I/O: the process is usually referred as making the system *green*, in |
3230 | +reference to the `green threads`_. |
3231 | + |
3232 | +Because Psycopg is a C extension module, it is not possible for coroutine |
3233 | +libraries to patch it: Psycopg instead enables cooperative multithreading by |
3234 | +allowing the registration of a *wait callback* using the |
3235 | +`psycopg2.extensions.set_wait_callback()` function. When a wait callback is |
3236 | +registered, Psycopg will use `libpq non-blocking calls`__ instead of the regular |
3237 | +blocking ones, and will delegate to the callback the responsibility to wait |
3238 | +for the socket to become readable or writable. |
3239 | + |
3240 | +Working this way, the caller does not have the complete freedom to schedule the |
3241 | +socket check whenever they want as with an :ref:`asynchronous connection |
3242 | +<async-support>`, but has the advantage of maintaining a complete |DBAPI| |
3243 | +semantics: from the point of view of the end user, all Psycopg functions and |
3244 | +objects will work transparently in the coroutine environment (blocking the |
3245 | +calling green thread and giving other green threads the possibility to be |
3246 | +scheduled), allowing non modified code and third party libraries (such as |
3247 | +SQLAlchemy_) to be used in coroutine-based programs. |
3248 | + |
3249 | +Notice that, while I/O correctly yields control to other coroutines, each |
3250 | +connection has a lock allowing a single cursor at a time to communicate with the |
3251 | +backend: such lock is not *green*, so blocking against it would block the |
3252 | +entire program waiting for data, not the single coroutine. Therefore, |
3253 | +programmers are advised to either avoid sharing connections between coroutines |
3254 | +or to use a library-friendly lock to synchronize shared connections, e.g. for |
3255 | +pooling. |
3256 | + |
3257 | +Coroutine libraries authors should provide a callback implementation (and |
3258 | +probably register it) to make Psycopg as green as they want. An example |
3259 | +callback (using `!select()` to block) is provided as |
3260 | +`psycopg2.extras.wait_select()`: it boils down to something similar to:: |
3261 | + |
3262 | + def wait_select(conn): |
3263 | + while 1: |
3264 | + state = conn.poll() |
3265 | + if state == extensions.POLL_OK: |
3266 | + break |
3267 | + elif state == extensions.POLL_READ: |
3268 | + select.select([conn.fileno()], [], []) |
3269 | + elif state == extensions.POLL_WRITE: |
3270 | + select.select([], [conn.fileno()], []) |
3271 | + else: |
3272 | + raise OperationalError("bad state from poll: %s" % state) |
3273 | + |
3274 | +.. _coroutine: http://en.wikipedia.org/wiki/Coroutine |
3275 | +.. _greenlet: http://pypi.python.org/pypi/greenlet |
3276 | +.. _green threads: http://en.wikipedia.org/wiki/Green_threads |
3277 | +.. _Eventlet: http://eventlet.net/ |
3278 | +.. _gevent: http://www.gevent.org/ |
3279 | +.. _SQLAlchemy: http://www.sqlalchemy.org/ |
3280 | +.. __: http://www.postgresql.org/docs/8.4/static/libpq-async.html |
3281 | + |
3282 | +.. warning:: |
3283 | + :ref:`COPY commands <copy>` are currently not supported when a wait callback |
3284 | + is registered, but they will be probably implemented in a future release. |
3285 | + |
3286 | + :ref:`Large objects <large-objects>` are not supported either: they are |
3287 | + not compatible with asynchronous connections. |
3288 | + |
3289 | + |
3290 | +.. testcode:: |
3291 | + :hide: |
3292 | + |
3293 | + aconn.close() |
3294 | + conn.rollback() |
3295 | + cur.execute("DROP TABLE atable") |
3296 | + conn.commit() |
3297 | + cur.close() |
3298 | + conn.close() |
3299 | |
3300 | === added file 'doc/html/_sources/connection.txt' |
3301 | --- doc/html/_sources/connection.txt 1970-01-01 00:00:00 +0000 |
3302 | +++ doc/html/_sources/connection.txt 2010-07-28 20:35:51 +0000 |
3303 | @@ -0,0 +1,365 @@ |
3304 | +The ``connection`` class |
3305 | +======================== |
3306 | + |
3307 | +.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com> |
3308 | + |
3309 | +.. testsetup:: |
3310 | + |
3311 | + from pprint import pprint |
3312 | + import psycopg2.extensions |
3313 | + |
3314 | + drop_test_table('foo') |
3315 | + |
3316 | +.. class:: connection |
3317 | + |
3318 | + Handles the connection to a PostgreSQL database instance. It encapsulates |
3319 | + a database session. |
3320 | + |
3321 | + Connections are created using the factory function |
3322 | + `~psycopg2.connect()`. |
3323 | + |
3324 | + Connections are thread safe and can be shared among many thread. See |
3325 | + :ref:`thread-safety` for details. |
3326 | + |
3327 | + .. method:: cursor([name] [, cursor_factory]) |
3328 | + |
3329 | + Return a new `cursor` object using the connection. |
3330 | + |
3331 | + If `name` is specified, the returned cursor will be a *server |
3332 | + side* (or *named*) cursor. Otherwise the cursor will be *client side*. |
3333 | + See :ref:`server-side-cursors` for further details. |
3334 | + |
3335 | + The `cursor_factory` argument can be used to create non-standard |
3336 | + cursors. The class returned should be a subclass of |
3337 | + `psycopg2.extensions.cursor`. See :ref:`subclassing-cursor` for |
3338 | + details. |
3339 | + |
3340 | + .. extension:: |
3341 | + |
3342 | + The `name` and `cursor_factory` parameters are Psycopg |
3343 | + extensions to the |DBAPI|. |
3344 | + |
3345 | + |
3346 | + .. index:: |
3347 | + pair: Transaction; Commit |
3348 | + |
3349 | + .. method:: commit() |
3350 | + |
3351 | + Commit any pending transaction to the database. Psycopg can be set to |
3352 | + perform automatic commits at each operation, see |
3353 | + `~connection.set_isolation_level()`. |
3354 | + |
3355 | + |
3356 | + .. index:: |
3357 | + pair: Transaction; Rollback |
3358 | + |
3359 | + .. method:: rollback() |
3360 | + |
3361 | + Roll back to the start of any pending transaction. Closing a |
3362 | + connection without committing the changes first will cause an implicit |
3363 | + rollback to be performed. |
3364 | + |
3365 | + |
3366 | + .. method:: close() |
3367 | + |
3368 | + Close the connection now (rather than whenever `__del__()` is |
3369 | + called). The connection will be unusable from this point forward; an |
3370 | + `~psycopg2.InterfaceError` will be raised if any operation is |
3371 | + attempted with the connection. The same applies to all cursor objects |
3372 | + trying to use the connection. Note that closing a connection without |
3373 | + committing the changes first will cause an implicit rollback to be |
3374 | + performed (unless a different isolation level has been selected: see |
3375 | + `~connection.set_isolation_level()`). |
3376 | + |
3377 | + |
3378 | + .. index:: |
3379 | + single: Exceptions; In the connection class |
3380 | + |
3381 | + .. rubric:: Excetptions as connection class attributes |
3382 | + |
3383 | + The `!connection` also exposes as attributes the same exceptions |
3384 | + available in the `psycopg2` module. See :ref:`dbapi-exceptions`. |
3385 | + |
3386 | + |
3387 | + .. extension:: |
3388 | + |
3389 | + The above methods are the only ones defined by the |DBAPI| protocol. |
3390 | + The Psycopg connection objects exports the following additional |
3391 | + methods and attributes. |
3392 | + |
3393 | + |
3394 | + .. attribute:: closed |
3395 | + |
3396 | + Read-only attribute reporting whether the database connection is open |
3397 | + (0) or closed (1). |
3398 | + |
3399 | + |
3400 | + .. method:: reset |
3401 | + |
3402 | + Reset the connection to the default. |
3403 | + |
3404 | + The method rolls back an eventual pending transaction and executes the |
3405 | + PostgreSQL |RESET|_ and |SET SESSION AUTHORIZATION|__ to revert the |
3406 | + session to the default values. |
3407 | + |
3408 | + .. |RESET| replace:: :sql:`RESET` |
3409 | + .. _RESET: http://www.postgresql.org/docs/8.4/static/sql-reset.html |
3410 | + |
3411 | + .. |SET SESSION AUTHORIZATION| replace:: :sql:`SET SESSION AUTHORIZATION` |
3412 | + .. __: http://www.postgresql.org/docs/8.4/static/sql-set-session-authorization.html |
3413 | + |
3414 | + .. versionadded:: 2.0.12 |
3415 | + |
3416 | + |
3417 | + .. attribute:: dsn |
3418 | + |
3419 | + Read-only string containing the connection string used by the |
3420 | + connection. |
3421 | + |
3422 | + |
3423 | + .. index:: |
3424 | + pair: Transaction; Autocommit |
3425 | + pair: Transaction; Isolation level |
3426 | + |
3427 | + .. _autocommit: |
3428 | + |
3429 | + .. attribute:: isolation_level |
3430 | + .. method:: set_isolation_level(level) |
3431 | + |
3432 | + Read or set the `transaction isolation level`_ for the current session. |
3433 | + The level defines the different phenomena that can happen in the |
3434 | + database between concurrent transactions. |
3435 | + |
3436 | + The value set or read is an integer: symbolic constants are defined in |
3437 | + the module `psycopg2.extensions`: see |
3438 | + :ref:`isolation-level-constants` for the available values. |
3439 | + |
3440 | + The default level is :sql:`READ COMMITTED`: at this level a |
3441 | + transaction is automatically started the first time a database command |
3442 | + is executed. If you want an *autocommit* mode, switch to |
3443 | + `~psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT` before |
3444 | + executing any command:: |
3445 | + |
3446 | + >>> conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) |
3447 | + |
3448 | + See also :ref:`transactions-control`. |
3449 | + |
3450 | + .. index:: |
3451 | + pair: Client; Encoding |
3452 | + |
3453 | + .. attribute:: encoding |
3454 | + .. method:: set_client_encoding(enc) |
3455 | + |
3456 | + Read or set the client encoding for the current session. The default |
3457 | + is the encoding defined by the database. It should be one of the |
3458 | + `characters set supported by PostgreSQL`__ |
3459 | + |
3460 | + .. __: http://www.postgresql.org/docs/8.4/static/multibyte.html |
3461 | + |
3462 | + |
3463 | + .. index:: |
3464 | + pair: Client; Logging |
3465 | + |
3466 | + .. attribute:: notices |
3467 | + |
3468 | + A list containing all the database messages sent to the client during |
3469 | + the session. |
3470 | + |
3471 | + .. doctest:: |
3472 | + :options: NORMALIZE_WHITESPACE |
3473 | + |
3474 | + >>> cur.execute("CREATE TABLE foo (id serial PRIMARY KEY);") |
3475 | + >>> pprint(conn.notices) |
3476 | + ['NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"\n', |
3477 | + 'NOTICE: CREATE TABLE will create implicit sequence "foo_id_seq" for serial column "foo.id"\n'] |
3478 | + |
3479 | + To avoid a leak in case excessive notices are generated, only the last |
3480 | + 50 messages are kept. |
3481 | + |
3482 | + You can configure what messages to receive using `PostgreSQL logging |
3483 | + configuration parameters`__ such as ``log_statement``, |
3484 | + ``client_min_messages``, ``log_min_duration_statement`` etc. |
3485 | + |
3486 | + .. __: http://www.postgresql.org/docs/8.4/static/runtime-config-logging.html |
3487 | + |
3488 | + |
3489 | + .. attribute:: notifies |
3490 | + |
3491 | + List containing asynchronous notifications received by the session. |
3492 | + |
3493 | + Received notifications have the form of a 2 items tuple |
3494 | + :samp:`({pid},{name})`, where :samp:`{pid}` is the PID of the backend |
3495 | + that sent the notification and :samp:`{name}` is the signal name |
3496 | + specified in the :sql:`NOTIFY` command. |
3497 | + |
3498 | + For other details see :ref:`async-notify`. |
3499 | + |
3500 | + .. index:: |
3501 | + pair: Backend; PID |
3502 | + |
3503 | + .. method:: get_backend_pid() |
3504 | + |
3505 | + Returns the process ID (PID) of the backend server process handling |
3506 | + this connection. |
3507 | + |
3508 | + Note that the PID belongs to a process executing on the database |
3509 | + server host, not the local host! |
3510 | + |
3511 | + .. seealso:: libpq docs for `PQbackendPID()`__ for details. |
3512 | + |
3513 | + .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33590 |
3514 | + |
3515 | + .. versionadded:: 2.0.8 |
3516 | + |
3517 | + |
3518 | + .. index:: |
3519 | + pair: Server; Parameters |
3520 | + |
3521 | + .. method:: get_parameter_status(parameter) |
3522 | + |
3523 | + Look up a current parameter setting of the server. |
3524 | + |
3525 | + Potential values for ``parameter`` are: ``server_version``, |
3526 | + ``server_encoding``, ``client_encoding``, ``is_superuser``, |
3527 | + ``session_authorization``, ``DateStyle``, ``TimeZone``, |
3528 | + ``integer_datetimes``, and ``standard_conforming_strings``. |
3529 | + |
3530 | + If server did not report requested parameter, return ``None``. |
3531 | + |
3532 | + .. seealso:: libpq docs for `PQparameterStatus()`__ for details. |
3533 | + |
3534 | + .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33499 |
3535 | + |
3536 | + .. versionadded:: 2.0.12 |
3537 | + |
3538 | + |
3539 | + .. index:: |
3540 | + pair: Transaction; Status |
3541 | + |
3542 | + .. method:: get_transaction_status() |
3543 | + |
3544 | + Return the current session transaction status as an integer. Symbolic |
3545 | + constants for the values are defined in the module |
3546 | + `psycopg2.extensions`: see :ref:`transaction-status-constants` |
3547 | + for the available values. |
3548 | + |
3549 | + .. seealso:: libpq docs for `PQtransactionStatus()`__ for details. |
3550 | + |
3551 | + .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33480 |
3552 | + |
3553 | + |
3554 | + .. index:: |
3555 | + pair: Protocol; Version |
3556 | + |
3557 | + .. attribute:: protocol_version |
3558 | + |
3559 | + A read-only integer representing frontend/backend protocol being used. |
3560 | + It can be 2 or 3. |
3561 | + |
3562 | + .. seealso:: libpq docs for `PQprotocolVersion()`__ for details. |
3563 | + |
3564 | + .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33546 |
3565 | + |
3566 | + .. versionadded:: 2.0.12 |
3567 | + |
3568 | + |
3569 | + .. index:: |
3570 | + pair: Server; Version |
3571 | + |
3572 | + .. attribute:: server_version |
3573 | + |
3574 | + A read-only integer representing the backend version. |
3575 | + |
3576 | + The number is formed by converting the major, minor, and revision |
3577 | + numbers into two-decimal-digit numbers and appending them together. |
3578 | + For example, version 8.1.5 will be returned as ``80105``. |
3579 | + |
3580 | + .. seealso:: libpq docs for `PQserverVersion()`__ for details. |
3581 | + |
3582 | + .. __: http://www.postgresql.org/docs/8.4/static/libpq-status.html#AEN33556 |
3583 | + |
3584 | + .. versionadded:: 2.0.12 |
3585 | + |
3586 | + |
3587 | + .. index:: |
3588 | + pair: Connection; Status |
3589 | + |
3590 | + .. attribute:: status |
3591 | + |
3592 | + A read-only integer representing the status of the connection. |
3593 | + Symbolic constants for the values are defined in the module |
3594 | + `psycopg2.extensions`: see :ref:`connection-status-constants` |
3595 | + for the available values. |
3596 | + |
3597 | + |
3598 | + .. method:: lobject([oid [, mode [, new_oid [, new_file [, lobject_factory]]]]]) |
3599 | + |
3600 | + Return a new database large object. See :ref:`large-objects` for an |
3601 | + overview. |
3602 | + |
3603 | + :param oid: The OID of the object to read or write. 0 to create |
3604 | + a new large object and and have its OID assigned automatically. |
3605 | + :param mode: Access mode to the object: can be ``r``, ``w``, |
3606 | + ``rw`` or ``n`` (meaning don't open it). |
3607 | + :param new_oid: Create a new object using the specified OID. The |
3608 | + function raises `OperationalError` if the OID is already in |
3609 | + use. Default is 0, meaning assign a new one automatically. |
3610 | + :param new_file: The name of a file to be imported in the the database |
3611 | + (using the |lo_import|_ function) |
3612 | + :param lobject_factory: Subclass of |
3613 | + `~psycopg2.extensions.lobject` to be instantiated. |
3614 | + :rtype: `~psycopg2.extensions.lobject` |
3615 | + |
3616 | + .. |lo_import| replace:: `!lo_import()` |
3617 | + .. _lo_import: http://www.postgresql.org/docs/8.4/static/lo-interfaces.html#AEN36307 |
3618 | + |
3619 | + .. versionadded:: 2.0.8 |
3620 | + |
3621 | + |
3622 | + |
3623 | + .. rubric:: Methods related to asynchronous support. |
3624 | + |
3625 | + .. versionadded:: 2.2.0 |
3626 | + |
3627 | + .. seealso:: :ref:`async-support` and :ref:`green-support`. |
3628 | + |
3629 | + |
3630 | + .. attribute:: async |
3631 | + |
3632 | + Read only attribute: 1 if the connection is asynchronous, 0 otherwse. |
3633 | + |
3634 | + |
3635 | + .. method:: poll() |
3636 | + |
3637 | + Used during an asynchronous connection attempt, or when a cursor is |
3638 | + executing a query on an asynchronous connection, make communication |
3639 | + proceed if it wouldn't block. |
3640 | + |
3641 | + Return one of the constants defined in :ref:`poll-constants`. If it |
3642 | + returns `~psycopg2.extensions.POLL_OK` then the connection has been |
3643 | + estabilished or the query results are available on the client. |
3644 | + Otherwise wait until the file descriptor returned by `fileno()` is |
3645 | + ready to read or to write, as explained in :ref:`async-support`. |
3646 | + `poll()` should be also used by the function installed by |
3647 | + `~psycopg2.extensions.set_wait_callback()` as explained in |
3648 | + :ref:`green-support`. |
3649 | + |
3650 | + `poll()` is also used to receive asynchronous notifications from the |
3651 | + database: see :ref:`async-notify` from further details. |
3652 | + |
3653 | + |
3654 | + .. method:: fileno() |
3655 | + |
3656 | + Return the file descriptor underlying the connection: useful to read |
3657 | + its status during asynchronous communication. |
3658 | + |
3659 | + |
3660 | + .. method:: isexecuting() |
3661 | + |
3662 | + Return `True` if the connection is executing an asynchronous operation. |
3663 | + |
3664 | + |
3665 | +.. testcode:: |
3666 | + :hide: |
3667 | + |
3668 | + conn.rollback() |
3669 | |
3670 | === added file 'doc/html/_sources/cursor.txt' |
3671 | --- doc/html/_sources/cursor.txt 1970-01-01 00:00:00 +0000 |
3672 | +++ doc/html/_sources/cursor.txt 2010-07-28 20:35:51 +0000 |
3673 | @@ -0,0 +1,473 @@ |
3674 | +The ``cursor`` class |
3675 | +==================== |
3676 | + |
3677 | +.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com> |
3678 | + |
3679 | +.. testsetup:: * |
3680 | + |
3681 | + from StringIO import StringIO |
3682 | + import sys |
3683 | + |
3684 | + create_test_table() |
3685 | + |
3686 | + # initial data |
3687 | + cur.executemany("INSERT INTO test (num, data) VALUES (%s, %s)", |
3688 | + [(100, "abc'def"), (None, 'dada'), (42, 'bar')]) |
3689 | + conn.commit() |
3690 | + |
3691 | + |
3692 | +.. class:: cursor |
3693 | + |
3694 | + Allows Python code to execute PostgreSQL command in a database session. |
3695 | + Cursors are created by the `connection.cursor()` method: they are |
3696 | + bound to the connection for the entire lifetime and all the commands are |
3697 | + executed in the context of the database session wrapped by the connection. |
3698 | + |
3699 | + Cursors created from the same connection are not isolated, i.e., any |
3700 | + changes done to the database by a cursor are immediately visible by the |
3701 | + other cursors. Cursors created from different connections can or can not |
3702 | + be isolated, depending on the connections' :ref:`isolation level |
3703 | + <transactions-control>`. See also `~connection.rollback()` and |
3704 | + `~connection.commit()` methods. |
3705 | + |
3706 | + Cursors are *not* thread safe: a multithread application can create |
3707 | + many cursors from the same connection and should use each cursor from |
3708 | + a single thread. See :ref:`thread-safety` for details. |
3709 | + |
3710 | + |
3711 | + .. attribute:: description |
3712 | + |
3713 | + This read-only attribute is a sequence of 7-item sequences. |
3714 | + |
3715 | + Each of these sequences contains information describing one result |
3716 | + column: |
3717 | + |
3718 | + - ``name`` |
3719 | + - ``type_code`` |
3720 | + - ``display_size`` |
3721 | + - ``internal_size`` |
3722 | + - ``precision`` |
3723 | + - ``scale`` |
3724 | + - ``null_ok`` |
3725 | + |
3726 | + The first two items (``name`` and ``type_code``) are always specified, |
3727 | + the other five are optional and are set to ``None`` if no meaningful |
3728 | + values can be provided. |
3729 | + |
3730 | + This attribute will be ``None`` for operations that do not return rows |
3731 | + or if the cursor has not had an operation invoked via the |
3732 | + |execute*|_ methods yet. |
3733 | + |
3734 | + The ``type_code`` can be interpreted by comparing it to the Type |
3735 | + Objects specified in the section :ref:`type-objects-and-constructors`. |
3736 | + It is also used to register typecasters to convert PostgreSQL types to |
3737 | + Python objects: see :ref:`type-casting-from-sql-to-python`. |
3738 | + |
3739 | + |
3740 | + .. method:: close() |
3741 | + |
3742 | + Close the cursor now (rather than whenever `!__del__()` is |
3743 | + called). The cursor will be unusable from this point forward; an |
3744 | + `~psycopg2.InterfaceError` will be raised if any operation is |
3745 | + attempted with the cursor. |
3746 | + |
3747 | + .. attribute:: closed |
3748 | + |
3749 | + Read-only boolean attribute: specifies if the cursor is closed |
3750 | + (``True``) or not (``False``). |
3751 | + |
3752 | + .. extension:: |
3753 | + |
3754 | + The `closed` attribute is a Psycopg extension to the |
3755 | + |DBAPI|. |
3756 | + |
3757 | + .. versionadded:: 2.0.7 |
3758 | + |
3759 | + |
3760 | + .. attribute:: connection |
3761 | + |
3762 | + Read-only attribute returning a reference to the `connection` |
3763 | + object on which the cursor was created. |
3764 | + |
3765 | + |
3766 | + .. attribute:: name |
3767 | + |
3768 | + Read-only attribute containing the name of the cursor if it was |
3769 | + creates as named cursor by `connection.cursor()`, or ``None`` if |
3770 | + it is a client side cursor. See :ref:`server-side-cursors`. |
3771 | + |
3772 | + .. extension:: |
3773 | + |
3774 | + The `name` attribute is a Psycopg extension to the |DBAPI|. |
3775 | + |
3776 | + |
3777 | + |
3778 | + .. |execute*| replace:: `execute*()` |
3779 | + |
3780 | + .. _execute*: |
3781 | + |
3782 | + .. rubric:: Commands execution methods |
3783 | + |
3784 | + |
3785 | + .. method:: execute(operation [, parameters]) |
3786 | + |
3787 | + Prepare and execute a database operation (query or command). |
3788 | + |
3789 | + Parameters may be provided as sequence or mapping and will be bound to |
3790 | + variables in the operation. Variables are specified either with |
3791 | + positional (``%s``) or named (:samp:`%({name})s`) placeholders. See |
3792 | + :ref:`query-parameters`. |
3793 | + |
3794 | + The method returns `None`. If a query was executed, the returned |
3795 | + values can be retrieved using |fetch*|_ methods. |
3796 | + |
3797 | + |
3798 | + .. method:: mogrify(operation [, parameters]) |
3799 | + |
3800 | + Return a query string after arguments binding. The string returned is |
3801 | + exactly the one that would be sent to the database running the |
3802 | + `~cursor.execute()` method or similar. |
3803 | + |
3804 | + >>> cur.mogrify("INSERT INTO test (num, data) VALUES (%s, %s)", (42, 'bar')) |
3805 | + "INSERT INTO test (num, data) VALUES (42, E'bar')" |
3806 | + |
3807 | + .. extension:: |
3808 | + |
3809 | + The `mogrify()` method is a Psycopg extension to the |DBAPI|. |
3810 | + |
3811 | + |
3812 | + .. method:: executemany(operation, seq_of_parameters) |
3813 | + |
3814 | + Prepare a database operation (query or command) and then execute it |
3815 | + against all parameter tuples or mappings found in the sequence |
3816 | + `seq_of_parameters`. |
3817 | + |
3818 | + The function is mostly useful for commands that update the database: |
3819 | + any result set returned by the query is discarded. |
3820 | + |
3821 | + Parameters are bounded to the query using the same rules described in |
3822 | + the `~cursor.execute()` method. |
3823 | + |
3824 | + |
3825 | + .. method:: callproc(procname [, parameters]) |
3826 | + |
3827 | + Call a stored database procedure with the given name. The sequence of |
3828 | + parameters must contain one entry for each argument that the procedure |
3829 | + expects. The result of the call is returned as modified copy of the |
3830 | + input sequence. Input parameters are left untouched, output and |
3831 | + input/output parameters replaced with possibly new values. |
3832 | + |
3833 | + The procedure may also provide a result set as output. This must then |
3834 | + be made available through the standard |fetch*|_ methods. |
3835 | + |
3836 | + |
3837 | + .. method:: setinputsizes(sizes) |
3838 | + |
3839 | + This method is exposed in compliance with the |DBAPI|. It currently |
3840 | + does nothing but it is safe to call it. |
3841 | + |
3842 | + |
3843 | + |
3844 | + .. |fetch*| replace:: `!fetch*()` |
3845 | + |
3846 | + .. _fetch*: |
3847 | + |
3848 | + .. rubric:: Results retrieval methods |
3849 | + |
3850 | + |
3851 | + The following methods are used to read data from the database after an |
3852 | + `~cursor.execute()` call. |
3853 | + |
3854 | + .. _cursor-iterable: |
3855 | + |
3856 | + .. note:: |
3857 | + |
3858 | + `cursor` objects are iterable, so, instead of calling |
3859 | + explicitly `~cursor.fetchone()` in a loop, the object itself can |
3860 | + be used: |
3861 | + |
3862 | + >>> cur.execute("SELECT * FROM test;") |
3863 | + >>> for record in cur: |
3864 | + ... print record |
3865 | + ... |
3866 | + (1, 100, "abc'def") |
3867 | + (2, None, 'dada') |
3868 | + (3, 42, 'bar') |
3869 | + |
3870 | + |
3871 | + .. method:: fetchone() |
3872 | + |
3873 | + Fetch the next row of a query result set, returning a single tuple, |
3874 | + or ``None`` when no more data is available: |
3875 | + |
3876 | + >>> cur.execute("SELECT * FROM test WHERE id = %s", (3,)) |
3877 | + >>> cur.fetchone() |
3878 | + (3, 42, 'bar') |
3879 | + |
3880 | + A `~psycopg2.ProgrammingError` is raised if the previous call |
3881 | + to |execute*|_ did not produce any result set or no call was issued |
3882 | + yet. |
3883 | + |
3884 | + |
3885 | + .. method:: fetchmany([size=cursor.arraysize]) |
3886 | + |
3887 | + Fetch the next set of rows of a query result, returning a list of |
3888 | + tuples. An empty list is returned when no more rows are available. |
3889 | + |
3890 | + The number of rows to fetch per call is specified by the parameter. |
3891 | + If it is not given, the cursor's `~cursor.arraysize` determines |
3892 | + the number of rows to be fetched. The method should try to fetch as |
3893 | + many rows as indicated by the size parameter. If this is not possible |
3894 | + due to the specified number of rows not being available, fewer rows |
3895 | + may be returned: |
3896 | + |
3897 | + >>> cur.execute("SELECT * FROM test;") |
3898 | + >>> cur.fetchmany(2) |
3899 | + [(1, 100, "abc'def"), (2, None, 'dada')] |
3900 | + >>> cur.fetchmany(2) |
3901 | + [(3, 42, 'bar')] |
3902 | + >>> cur.fetchmany(2) |
3903 | + [] |
3904 | + |
3905 | + A `~psycopg2.ProgrammingError` is raised if the previous call to |
3906 | + |execute*|_ did not produce any result set or no call was issued yet. |
3907 | + |
3908 | + Note there are performance considerations involved with the size |
3909 | + parameter. For optimal performance, it is usually best to use the |
3910 | + `~cursor.arraysize` attribute. If the size parameter is used, |
3911 | + then it is best for it to retain the same value from one |
3912 | + `fetchmany()` call to the next. |
3913 | + |
3914 | + |
3915 | + .. method:: fetchall() |
3916 | + |
3917 | + Fetch all (remaining) rows of a query result, returning them as a list |
3918 | + of tuples. An empty list is returned if there is no more record to |
3919 | + fetch. |
3920 | + |
3921 | + >>> cur.execute("SELECT * FROM test;") |
3922 | + >>> cur.fetchall() |
3923 | + [(1, 100, "abc'def"), (2, None, 'dada'), (3, 42, 'bar')] |
3924 | + |
3925 | + A `~psycopg2.ProgrammingError` is raised if the previous call to |
3926 | + |execute*|_ did not produce any result set or no call was issued yet. |
3927 | + |
3928 | + |
3929 | + .. method:: scroll(value [, mode='relative']) |
3930 | + |
3931 | + Scroll the cursor in the result set to a new position according |
3932 | + to mode. |
3933 | + |
3934 | + If `mode` is ``relative`` (default), value is taken as offset to |
3935 | + the current position in the result set, if set to ``absolute``, |
3936 | + value states an absolute target position. |
3937 | + |
3938 | + If the scroll operation would leave the result set, a |
3939 | + `~psycopg2.ProgrammingError` is raised and the cursor position is |
3940 | + not changed. |
3941 | + |
3942 | + The method can be used both for client-side cursors and |
3943 | + :ref:`server-side cursors <server-side-cursors>`. |
3944 | + |
3945 | + .. note:: |
3946 | + |
3947 | + According to the |DBAPI|_, the exception raised for a cursor out |
3948 | + of bound should have been `!IndexError`. The best option is |
3949 | + probably to catch both exceptions in your code:: |
3950 | + |
3951 | + try: |
3952 | + cur.scroll(1000 * 1000) |
3953 | + except (ProgrammingError, IndexError), exc: |
3954 | + deal_with_it(exc) |
3955 | + |
3956 | + |
3957 | + .. attribute:: arraysize |
3958 | + |
3959 | + This read/write attribute specifies the number of rows to fetch at a |
3960 | + time with `~cursor.fetchmany()`. It defaults to 1 meaning to fetch |
3961 | + a single row at a time. |
3962 | + |
3963 | + |
3964 | + .. attribute:: rowcount |
3965 | + |
3966 | + This read-only attribute specifies the number of rows that the last |
3967 | + |execute*|_ produced (for :abbr:`DQL (Data Query Language)` statements |
3968 | + like :sql:`SELECT`) or affected (for |
3969 | + :abbr:`DML (Data Manipulation Language)` statements like :sql:`UPDATE` |
3970 | + or :sql:`INSERT`). |
3971 | + |
3972 | + The attribute is -1 in case no |execute*| has been performed on |
3973 | + the cursor or the row count of the last operation if it can't be |
3974 | + determined by the interface. |
3975 | + |
3976 | + .. note:: |
3977 | + The |DBAPI|_ interface reserves to redefine the latter case to |
3978 | + have the object return ``None`` instead of -1 in future versions |
3979 | + of the specification. |
3980 | + |
3981 | + |
3982 | + .. attribute:: rownumber |
3983 | + |
3984 | + This read-only attribute provides the current 0-based index of the |
3985 | + cursor in the result set or ``None`` if the index cannot be |
3986 | + determined. |
3987 | + |
3988 | + The index can be seen as index of the cursor in a sequence (the result |
3989 | + set). The next fetch operation will fetch the row indexed by |
3990 | + `rownumber` in that sequence. |
3991 | + |
3992 | + |
3993 | + .. index:: oid |
3994 | + |
3995 | + .. attribute:: lastrowid |
3996 | + |
3997 | + This read-only attribute provides the OID of the last row inserted |
3998 | + by the cursor. If the table wasn't created with OID support or the |
3999 | + last operation is not a single record insert, the attribute is set to |
4000 | + ``None``. |
4001 | + |
4002 | + PostgreSQL currently advices to not create OIDs on the tables and the |
4003 | + default for |CREATE-TABLE|__ is to not support them. The |
4004 | + |INSERT-RETURNING|__ syntax available from PostgreSQL 8.3 allows more |
4005 | + flexibility. |
4006 | + |
4007 | + .. |CREATE-TABLE| replace:: :sql:`CREATE TABLE` |
4008 | + .. __: http://www.postgresql.org/docs/8.4/static/sql-createtable.html |
4009 | + |
4010 | + .. |INSERT-RETURNING| replace:: :sql:`INSERT ... RETURNING` |
4011 | + .. __: http://www.postgresql.org/docs/8.4/static/sql-insert.html |
4012 | + |
4013 | + |
4014 | + .. method:: nextset() |
4015 | + |
4016 | + This method is not supported (PostgreSQL does not have multiple data |
4017 | + sets) and will raise a `~psycopg2.NotSupportedError` exception. |
4018 | + |
4019 | + |
4020 | + .. method:: setoutputsize(size [, column]) |
4021 | + |
4022 | + This method is exposed in compliance with the |DBAPI|. It currently |
4023 | + does nothing but it is safe to call it. |
4024 | + |
4025 | + |
4026 | + .. attribute:: query |
4027 | + |
4028 | + Read-only attribute containing the body of the last query sent to the |
4029 | + backend (including bound arguments). ``None`` if no query has been |
4030 | + executed yet: |
4031 | + |
4032 | + >>> cur.execute("INSERT INTO test (num, data) VALUES (%s, %s)", (42, 'bar')) |
4033 | + >>> cur.query |
4034 | + "INSERT INTO test (num, data) VALUES (42, E'bar')" |
4035 | + |
4036 | + .. extension:: |
4037 | + |
4038 | + The `query` attribute is a Psycopg extension to the |DBAPI|. |
4039 | + |
4040 | + |
4041 | + .. attribute:: statusmessage |
4042 | + |
4043 | + Read-only attribute containing the message returned by the last |
4044 | + command: |
4045 | + |
4046 | + >>> cur.execute("INSERT INTO test (num, data) VALUES (%s, %s)", (42, 'bar')) |
4047 | + >>> cur.statusmessage |
4048 | + 'INSERT 0 1' |
4049 | + |
4050 | + .. extension:: |
4051 | + |
4052 | + The `statusmessage` attribute is a Psycopg extension to the |
4053 | + |DBAPI|. |
4054 | + |
4055 | + |
4056 | + .. attribute:: tzinfo_factory |
4057 | + |
4058 | + The time zone factory used to handle data types such as |
4059 | + :sql:`TIMESTAMP WITH TIME ZONE`. It should be a |tzinfo|_ object. |
4060 | + See also the `psycopg2.tz` module. |
4061 | + |
4062 | + .. |tzinfo| replace:: `!tzinfo` |
4063 | + .. _tzinfo: http://docs.python.org/library/datetime.html#tzinfo-objects |
4064 | + |
4065 | + |
4066 | + .. rubric:: COPY-related methods |
4067 | + |
4068 | + .. extension:: |
4069 | + |
4070 | + The :sql:`COPY` command is a PostgreSQL extension to the SQL standard. |
4071 | + As such, its support is a Psycopg extension to the |DBAPI|. |
4072 | + |
4073 | + .. method:: copy_from(file, table, sep='\\t', null='\\N', columns=None) |
4074 | + |
4075 | + Read data *from* the file-like object `file` appending them to |
4076 | + the table named `table`. `file` must have both |
4077 | + `!read()` and `!readline()` method. See :ref:`copy` for an |
4078 | + overview. |
4079 | + |
4080 | + The optional argument `sep` is the columns separator and |
4081 | + `null` represents :sql:`NULL` values in the file. |
4082 | + |
4083 | + The `columns` argument is a sequence containing the name of the |
4084 | + fields where the read data will be entered. Its length and column |
4085 | + type should match the content of the read file. If not specifies, it |
4086 | + is assumed that the entire table matches the file structure. |
4087 | + |
4088 | + >>> f = StringIO("42\tfoo\n74\tbar\n") |
4089 | + >>> cur.copy_from(f, 'test', columns=('num', 'data')) |
4090 | + >>> cur.execute("select * from test where id > 5;") |
4091 | + >>> cur.fetchall() |
4092 | + [(6, 42, 'foo'), (7, 74, 'bar')] |
4093 | + |
4094 | + .. versionchanged:: 2.0.6 |
4095 | + added the `columns` parameter. |
4096 | + |
4097 | + |
4098 | + .. method:: copy_to(file, table, sep='\\t', null='\\N', columns=None) |
4099 | + |
4100 | + Write the content of the table named `table` *to* the file-like |
4101 | + object `file`. `file` must have a `!write()` method. |
4102 | + See :ref:`copy` for an overview. |
4103 | + |
4104 | + The optional argument `sep` is the columns separator and |
4105 | + `null` represents :sql:`NULL` values in the file. |
4106 | + |
4107 | + The `columns` argument is a sequence of field names: if not |
4108 | + ``None`` only the specified fields will be included in the dump. |
4109 | + |
4110 | + >>> cur.copy_to(sys.stdout, 'test', sep="|") |
4111 | + 1|100|abc'def |
4112 | + 2|\N|dada |
4113 | + ... |
4114 | + |
4115 | + .. versionchanged:: 2.0.6 |
4116 | + added the `columns` parameter. |
4117 | + |
4118 | + |
4119 | + .. method:: copy_expert(sql, file [, size]) |
4120 | + |
4121 | + Submit a user-composed :sql:`COPY` statement. The method is useful to |
4122 | + handle all the parameters that PostgreSQL makes available (see |
4123 | + |COPY|__ command documentation). |
4124 | + |
4125 | + `file` must be an open, readable file for :sql:`COPY FROM` or an |
4126 | + open, writeable file for :sql:`COPY TO`. The optional `size` |
4127 | + argument, when specified for a :sql:`COPY FROM` statement, will be |
4128 | + passed to `file`\ 's read method to control the read buffer |
4129 | + size. |
4130 | + |
4131 | + >>> cur.copy_expert("COPY test TO STDOUT WITH CSV HEADER", sys.stdout) |
4132 | + id,num,data |
4133 | + 1,100,abc'def |
4134 | + 2,,dada |
4135 | + ... |
4136 | + |
4137 | + .. |COPY| replace:: :sql:`COPY` |
4138 | + .. __: http://www.postgresql.org/docs/8.4/static/sql-copy.html |
4139 | + |
4140 | + .. versionadded:: 2.0.6 |
4141 | + |
4142 | + |
4143 | +.. testcode:: |
4144 | + :hide: |
4145 | + |
4146 | + conn.rollback() |
4147 | |
4148 | === added file 'doc/html/_sources/errorcodes.txt' |
4149 | --- doc/html/_sources/errorcodes.txt 1970-01-01 00:00:00 +0000 |
4150 | +++ doc/html/_sources/errorcodes.txt 2010-07-28 20:35:51 +0000 |
4151 | @@ -0,0 +1,76 @@ |
4152 | +`psycopg2.errorcodes` -- Error codes defined by PostgreSQL |
4153 | +=============================================================== |
4154 | + |
4155 | +.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com> |
4156 | + |
4157 | +.. index:: |
4158 | + single: Error; Codes |
4159 | + |
4160 | +.. module:: psycopg2.errorcodes |
4161 | + |
4162 | +.. testsetup:: * |
4163 | + |
4164 | + from psycopg2 import errorcodes |
4165 | + |
4166 | +.. versionadded:: 2.0.6 |
4167 | + |
4168 | +This module contains symbolic names for all PostgreSQL error codes and error |
4169 | +classes codes. Subclasses of `~psycopg2.Error` make the PostgreSQL error |
4170 | +code available in the `~psycopg2.Error.pgcode` attribute. |
4171 | + |
4172 | +From PostgreSQL documentation: |
4173 | + |
4174 | + All messages emitted by the PostgreSQL server are assigned five-character |
4175 | + error codes that follow the SQL standard's conventions for :sql:`SQLSTATE` |
4176 | + codes. Applications that need to know which error condition has occurred |
4177 | + should usually test the error code, rather than looking at the textual |
4178 | + error message. The error codes are less likely to change across |
4179 | + PostgreSQL releases, and also are not subject to change due to |
4180 | + localization of error messages. Note that some, but not all, of the error |
4181 | + codes produced by PostgreSQL are defined by the SQL standard; some |
4182 | + additional error codes for conditions not defined by the standard have |
4183 | + been invented or borrowed from other databases. |
4184 | + |
4185 | + According to the standard, the first two characters of an error code |
4186 | + denote a class of errors, while the last three characters indicate a |
4187 | + specific condition within that class. Thus, an application that does not |
4188 | + recognize the specific error code can still be able to infer what to do |
4189 | + from the error class. |
4190 | + |
4191 | +.. seealso:: `PostgreSQL Error Codes table`__ |
4192 | + |
4193 | + .. __: http://www.postgresql.org/docs/8.4/static/errcodes-appendix.html#ERRCODES-TABLE |
4194 | + |
4195 | + |
4196 | +An example of the available constants defined in the module: |
4197 | + |
4198 | + >>> errorcodes.CLASS_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION |
4199 | + '42' |
4200 | + >>> errorcodes.UNDEFINED_TABLE |
4201 | + '42P01' |
4202 | + |
4203 | +Constants representing all the error values documented by PostgreSQL versions |
4204 | +between 8.1 and 8.4 are included in the module. |
4205 | + |
4206 | + |
4207 | +.. autofunction:: lookup(code) |
4208 | + |
4209 | + .. doctest:: |
4210 | + |
4211 | + >>> try: |
4212 | + ... cur.execute("SELECT ouch FROM aargh;") |
4213 | + ... except Exception, e: |
4214 | + ... pass |
4215 | + ... |
4216 | + >>> errorcodes.lookup(e.pgcode[:2]) |
4217 | + 'CLASS_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION' |
4218 | + >>> errorcodes.lookup(e.pgcode) |
4219 | + 'UNDEFINED_TABLE' |
4220 | + |
4221 | + .. versionadded:: 2.0.14 |
4222 | + |
4223 | + |
4224 | +.. testcode:: |
4225 | + :hide: |
4226 | + |
4227 | + conn.rollback() |
4228 | |
4229 | === added file 'doc/html/_sources/extensions.txt' |
4230 | --- doc/html/_sources/extensions.txt 1970-01-01 00:00:00 +0000 |
4231 | +++ doc/html/_sources/extensions.txt 2010-07-28 20:35:51 +0000 |
4232 | @@ -0,0 +1,565 @@ |
4233 | +`psycopg2.extensions` -- Extensions to the DB API |
4234 | +====================================================== |
4235 | + |
4236 | +.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com> |
4237 | + |
4238 | +.. module:: psycopg2.extensions |
4239 | + |
4240 | +.. testsetup:: * |
4241 | + |
4242 | + from psycopg2.extensions import AsIs, Binary, QuotedString, ISOLATION_LEVEL_AUTOCOMMIT |
4243 | + |
4244 | +The module contains a few objects and function extending the minimum set of |
4245 | +functionalities defined by the |DBAPI|_. |
4246 | + |
4247 | + |
4248 | +.. class:: connection |
4249 | + |
4250 | + Is the class usually returned by the `~psycopg2.connect()` function. |
4251 | + It is exposed by the `extensions` module in order to allow |
4252 | + subclassing to extend its behaviour: the subclass should be passed to the |
4253 | + `!connect()` function using the `connection_factory` parameter. |
4254 | + See also :ref:`subclassing-connection`. |
4255 | + |
4256 | + Subclasses should have constructor signature :samp:`({dsn}, {async}=0)`. |
4257 | + |
4258 | + For a complete description of the class, see `connection`. |
4259 | + |
4260 | +.. class:: cursor |
4261 | + |
4262 | + It is the class usually returnded by the `connection.cursor()` |
4263 | + method. It is exposed by the `extensions` module in order to allow |
4264 | + subclassing to extend its behaviour: the subclass should be passed to the |
4265 | + `!cursor()` method using the `cursor_factory` parameter. See |
4266 | + also :ref:`subclassing-cursor`. |
4267 | + |
4268 | + For a complete description of the class, see `cursor`. |
4269 | + |
4270 | +.. class:: lobject(conn [, oid [, mode [, new_oid [, new_file ]]]]) |
4271 | + |
4272 | + Wrapper for a PostgreSQL large object. See :ref:`large-objects` for an |
4273 | + overview. |
4274 | + |
4275 | + The class can be subclassed: see the `connection.lobject()` to know |
4276 | + how to specify a `!lobject` subclass. |
4277 | + |
4278 | + .. versionadded:: 2.0.8 |
4279 | + |
4280 | + .. attribute:: oid |
4281 | + |
4282 | + Database OID of the object. |
4283 | + |
4284 | + .. attribute:: mode |
4285 | + |
4286 | + The mode the database was open (``r``, ``w``, ``rw`` or ``n``). |
4287 | + |
4288 | + .. method:: read(bytes=-1) |
4289 | + |
4290 | + Read a chunk of data from the current file position. If -1 (default) |
4291 | + read all the remaining data. |
4292 | + |
4293 | + .. method:: write(str) |
4294 | + |
4295 | + Write a string to the large object. Return the number of bytes |
4296 | + written. |
4297 | + |
4298 | + .. method:: export(file_name) |
4299 | + |
4300 | + Export the large object content to the file system. |
4301 | + |
4302 | + The method uses the efficient |lo_export|_ libpq function. |
4303 | + |
4304 | + .. |lo_export| replace:: `!lo_export()` |
4305 | + .. _lo_export: http://www.postgresql.org/docs/8.4/static/lo-interfaces.html#AEN36330 |
4306 | + |
4307 | + .. method:: seek(offset, whence=0) |
4308 | + |
4309 | + Set the lobject current position. |
4310 | + |
4311 | + .. method:: tell() |
4312 | + |
4313 | + Return the lobject current position. |
4314 | + |
4315 | + .. method:: truncate(len=0) |
4316 | + |
4317 | + .. versionadded:: 2.2.0 |
4318 | + |
4319 | + Truncate the lobject to the given size. |
4320 | + |
4321 | + The method will only be available if Psycopg has been built against libpq |
4322 | + from PostgreSQL 8.3 or later and can only be used with PostgreSQL servers |
4323 | + running these versions. It uses the |lo_truncate|_ libpq function. |
4324 | + |
4325 | + .. |lo_truncate| replace:: `!lo_truncate()` |
4326 | + .. _lo_truncate: http://www.postgresql.org/docs/8.4/static/lo-interfaces.html#AEN36420 |
4327 | + |
4328 | + .. method:: close() |
4329 | + |
4330 | + Close the object. |
4331 | + |
4332 | + .. attribute:: closed |
4333 | + |
4334 | + Boolean attribute specifying if the object is closed. |
4335 | + |
4336 | + .. method:: unlink() |
4337 | + |
4338 | + Close the object and remove it from the database. |
4339 | + |
4340 | + |
4341 | +.. autofunction:: set_wait_callback(f) |
4342 | + |
4343 | + .. versionadded:: 2.2.0 |
4344 | + |
4345 | +.. autofunction:: get_wait_callback() |
4346 | + |
4347 | + .. versionadded:: 2.2.0 |
4348 | + |
4349 | + |
4350 | +.. _sql-adaptation-objects: |
4351 | + |
4352 | +SQL adaptation protocol objects |
4353 | +------------------------------- |
4354 | + |
4355 | +Psycopg provides a flexible system to adapt Python objects to the SQL syntax |
4356 | +(inspired to the :pep:`246`), allowing serialization in PostgreSQL. See |
4357 | +:ref:`adapting-new-types` for a detailed description. The following objects |
4358 | +deal with Python objects adaptation: |
4359 | + |
4360 | +.. function:: adapt(obj) |
4361 | + |
4362 | + Return the SQL representation of *obj* as a string. Raise a |
4363 | + `~psycopg2.ProgrammingError` if how to adapt the object is unknown. |
4364 | + In order to allow new objects to be adapted, register a new adapter for it |
4365 | + using the `register_adapter()` function. |
4366 | + |
4367 | + The function is the entry point of the adaptation mechanism: it can be |
4368 | + used to write adapters for complex objects by recursively calling |
4369 | + `!adapt()` on its components. |
4370 | + |
4371 | +.. function:: register_adapter(class, adapter) |
4372 | + |
4373 | + Register a new adapter for the objects of class *class*. |
4374 | + |
4375 | + *adapter* should be a function taking a single argument (the object |
4376 | + to adapt) and returning an object conforming the `ISQLQuote` |
4377 | + protocol (e.g. exposing a `!getquoted()` method). The `AsIs` is |
4378 | + often useful for this task. |
4379 | + |
4380 | + Once an object is registered, it can be safely used in SQL queries and by |
4381 | + the `adapt()` function. |
4382 | + |
4383 | +.. class:: ISQLQuote(wrapped_object) |
4384 | + |
4385 | + Represents the SQL adaptation protocol. Objects conforming this protocol |
4386 | + should implement a `!getquoted()` method. |
4387 | + |
4388 | + Adapters may subclass `!ISQLQuote`, but is not necessary: it is |
4389 | + enough to expose a `!getquoted()` method to be conforming. |
4390 | + |
4391 | + .. attribute:: _wrapped |
4392 | + |
4393 | + The wrapped object passes to the constructor |
4394 | + |
4395 | + .. method:: getquoted() |
4396 | + |
4397 | + Subclasses or other conforming objects should return a valid SQL |
4398 | + string representing the wrapped object. The `!ISQLQuote` |
4399 | + implementation does nothing. |
4400 | + |
4401 | +.. class:: AsIs |
4402 | + |
4403 | + Adapter conform to the `ISQLQuote` protocol useful for objects |
4404 | + whose string representation is already valid as SQL representation. |
4405 | + |
4406 | + .. method:: getquoted() |
4407 | + |
4408 | + Return the `str()` conversion of the wrapped object. |
4409 | + |
4410 | + >>> AsIs(42).getquoted() |
4411 | + '42' |
4412 | + |
4413 | +.. class:: QuotedString |
4414 | + |
4415 | + Adapter conform to the `ISQLQuote` protocol for string-like |
4416 | + objects. |
4417 | + |
4418 | + .. method:: getquoted() |
4419 | + |
4420 | + Return the string enclosed in single quotes. Any single quote |
4421 | + appearing in the the string is escaped by doubling it according to SQL |
4422 | + string constants syntax. Backslashes are escaped too. |
4423 | + |
4424 | + >>> QuotedString(r"O'Reilly").getquoted() |
4425 | + "'O''Reilly'" |
4426 | + |
4427 | +.. class:: Binary |
4428 | + |
4429 | + Adapter conform to the `ISQLQuote` protocol for binary objects. |
4430 | + |
4431 | + .. method:: getquoted() |
4432 | + |
4433 | + Return the string enclosed in single quotes. It performs the same |
4434 | + escaping of the `QuotedString` adapter, plus it knows how to |
4435 | + escape non-printable chars. |
4436 | + |
4437 | + >>> Binary("\x00\x08\x0F").getquoted() |
4438 | + "'\\\\000\\\\010\\\\017'" |
4439 | + |
4440 | + .. versionchanged:: 2.0.14 |
4441 | + previously the adapter was not exposed by the `extensions` |
4442 | + module. In older versions it can be imported from the implementation |
4443 | + module `!psycopg2._psycopg`. |
4444 | + |
4445 | + |
4446 | + |
4447 | +.. class:: Boolean |
4448 | + Float |
4449 | + SQL_IN |
4450 | + |
4451 | + Specialized adapters for builtin objects. |
4452 | + |
4453 | +.. class:: DateFromPy |
4454 | + TimeFromPy |
4455 | + TimestampFromPy |
4456 | + IntervalFromPy |
4457 | + |
4458 | + Specialized adapters for Python datetime objects. |
4459 | + |
4460 | +.. class:: DateFromMx |
4461 | + TimeFromMx |
4462 | + TimestampFromMx |
4463 | + IntervalFromMx |
4464 | + |
4465 | + Specialized adapters for `mx.DateTime`_ objects. |
4466 | + |
4467 | +.. data:: adapters |
4468 | + |
4469 | + Dictionary of the currently registered object adapters. Use |
4470 | + `register_adapter()` to add an adapter for a new type. |
4471 | + |
4472 | + |
4473 | + |
4474 | +Database types casting functions |
4475 | +-------------------------------- |
4476 | + |
4477 | +These functions are used to manipulate type casters to convert from PostgreSQL |
4478 | +types to Python objects. See :ref:`type-casting-from-sql-to-python` for |
4479 | +details. |
4480 | + |
4481 | +.. function:: new_type(oids, name, adapter) |
4482 | + |
4483 | + Create a new type caster to convert from a PostgreSQL type to a Python |
4484 | + object. The created object must be registered using |
4485 | + `register_type()` to be used. |
4486 | + |
4487 | + :param oids: tuple of OIDs of the PostgreSQL type to convert. |
4488 | + :param name: the name of the new type adapter. |
4489 | + :param adapter: the adaptation function. |
4490 | + |
4491 | + The object OID can be read from the `cursor.description` attribute |
4492 | + or by querying from the PostgreSQL catalog. |
4493 | + |
4494 | + *adapter* should have signature :samp:`fun({value}, {cur})` where |
4495 | + *value* is the string representation returned by PostgreSQL and |
4496 | + *cur* is the cursor from which data are read. In case of |
4497 | + :sql:`NULL`, *value* will be ``None``. The adapter should return the |
4498 | + converted object. |
4499 | + |
4500 | + See :ref:`type-casting-from-sql-to-python` for an usage example. |
4501 | + |
4502 | + |
4503 | +.. function:: register_type(obj [, scope]) |
4504 | + |
4505 | + Register a type caster created using `new_type()`. |
4506 | + |
4507 | + If *scope* is specified, it should be a `connection` or a |
4508 | + `cursor`: the type caster will be effective only limited to the |
4509 | + specified object. Otherwise it will be globally registered. |
4510 | + |
4511 | + |
4512 | +.. data:: string_types |
4513 | + |
4514 | + The global register of type casters. |
4515 | + |
4516 | + |
4517 | +.. index:: |
4518 | + single: Encoding; Mapping |
4519 | + |
4520 | +.. data:: encodings |
4521 | + |
4522 | + Mapping from `PostgreSQL encoding`__ names to `Python codec`__ names. |
4523 | + Used by Psycopg when adapting or casting unicode strings. See |
4524 | + :ref:`unicode-handling`. |
4525 | + |
4526 | + .. __: http://www.postgresql.org/docs/8.4/static/multibyte.html |
4527 | + .. __: http://docs.python.org/library/codecs.html#standard-encodings |
4528 | + |
4529 | + |
4530 | + |
4531 | +.. index:: |
4532 | + single: Exceptions; Additional |
4533 | + |
4534 | +Additional exceptions |
4535 | +--------------------- |
4536 | + |
4537 | +The module exports a few exceptions in addition to the :ref:`standard ones |
4538 | +<dbapi-exceptions>` defined by the |DBAPI|_. |
4539 | + |
4540 | +.. exception:: QueryCanceledError |
4541 | + |
4542 | + (subclasses `~psycopg2.OperationalError`) |
4543 | + |
4544 | + Error related to SQL query cancelation. It can be trapped specifically to |
4545 | + detect a timeout. |
4546 | + |
4547 | + .. versionadded:: 2.0.7 |
4548 | + |
4549 | + |
4550 | +.. exception:: TransactionRollbackError |
4551 | + |
4552 | + (subclasses `~psycopg2.OperationalError`) |
4553 | + |
4554 | + Error causing transaction rollback (deadlocks, serialisation failures, |
4555 | + etc). It can be trapped specifically to detect a deadlock. |
4556 | + |
4557 | + .. versionadded:: 2.0.7 |
4558 | + |
4559 | + |
4560 | + |
4561 | +.. index:: |
4562 | + pair: Isolation level; Constants |
4563 | + |
4564 | +.. _isolation-level-constants: |
4565 | + |
4566 | +Isolation level constants |
4567 | +------------------------- |
4568 | + |
4569 | +Psycopg2 `connection` objects hold informations about the PostgreSQL |
4570 | +`transaction isolation level`_. The current transaction level can be read |
4571 | +from the `~connection.isolation_level` attribute. The default isolation |
4572 | +level is :sql:`READ COMMITTED`. A different isolation level con be set |
4573 | +through the `~connection.set_isolation_level()` method. The level can be |
4574 | +set to one of the following constants: |
4575 | + |
4576 | +.. data:: ISOLATION_LEVEL_AUTOCOMMIT |
4577 | + |
4578 | + No transaction is started when command are issued and no |
4579 | + `~connection.commit()` or `~connection.rollback()` is required. |
4580 | + Some PostgreSQL command such as :sql:`CREATE DATABASE` or :sql:`VACUUM` |
4581 | + can't run into a transaction: to run such command use:: |
4582 | + |
4583 | + >>> conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) |
4584 | + |
4585 | + See also :ref:`transactions-control`. |
4586 | + |
4587 | +.. data:: ISOLATION_LEVEL_READ_UNCOMMITTED |
4588 | + |
4589 | + The :sql:`READ UNCOMMITTED` isolation level is defined in the SQL standard |
4590 | + but not available in the |MVCC| model of PostgreSQL: it is replaced by the |
4591 | + stricter :sql:`READ COMMITTED`. |
4592 | + |
4593 | +.. data:: ISOLATION_LEVEL_READ_COMMITTED |
4594 | + |
4595 | + This is the default value. A new transaction is started at the first |
4596 | + `~cursor.execute()` command on a cursor and at each new |
4597 | + `!execute()` after a `~connection.commit()` or a |
4598 | + `~connection.rollback()`. The transaction runs in the PostgreSQL |
4599 | + :sql:`READ COMMITTED` isolation level. |
4600 | + |
4601 | +.. data:: ISOLATION_LEVEL_REPEATABLE_READ |
4602 | + |
4603 | + The :sql:`REPEATABLE READ` isolation level is defined in the SQL standard |
4604 | + but not available in the |MVCC| model of PostgreSQL: it is replaced by the |
4605 | + stricter :sql:`SERIALIZABLE`. |
4606 | + |
4607 | +.. data:: ISOLATION_LEVEL_SERIALIZABLE |
4608 | + |
4609 | + Transactions are run at a :sql:`SERIALIZABLE` isolation level. This is the |
4610 | + strictest transactions isolation level, equivalent to having the |
4611 | + transactions executed serially rather than concurrently. However |
4612 | + applications using this level must be prepared to retry reansactions due |
4613 | + to serialization failures. See `serializable isolation level`_ in |
4614 | + PostgreSQL documentation. |
4615 | + |
4616 | + |
4617 | + |
4618 | +.. index:: |
4619 | + pair: Transaction status; Constants |
4620 | + |
4621 | +.. _transaction-status-constants: |
4622 | + |
4623 | +Transaction status constants |
4624 | +---------------------------- |
4625 | + |
4626 | +These values represent the possible status of a transaction: the current value |
4627 | +can be read using the `connection.get_transaction_status()` method. |
4628 | + |
4629 | +.. data:: TRANSACTION_STATUS_IDLE |
4630 | + |
4631 | + The session is idle and there is no current transaction. |
4632 | + |
4633 | +.. data:: TRANSACTION_STATUS_ACTIVE |
4634 | + |
4635 | + A command is currently in progress. |
4636 | + |
4637 | +.. data:: TRANSACTION_STATUS_INTRANS |
4638 | + |
4639 | + The session is idle in a valid transaction block. |
4640 | + |
4641 | +.. data:: TRANSACTION_STATUS_INERROR |
4642 | + |
4643 | + The session is idle in a failed transaction block. |
4644 | + |
4645 | +.. data:: TRANSACTION_STATUS_UNKNOWN |
4646 | + |
4647 | + Reported if the connection with the server is bad. |
4648 | + |
4649 | + |
4650 | + |
4651 | +.. index:: |
4652 | + pair: Connection status; Constants |
4653 | + |
4654 | +.. _connection-status-constants: |
4655 | + |
4656 | +Connection status constants |
4657 | +--------------------------- |
4658 | + |
4659 | +These values represent the possible status of a connection: the current value |
4660 | +can be read from the `~connection.status` attribute. |
4661 | + |
4662 | +It is possible to find the connection in other status than the one shown below. |
4663 | +Those are the only states in which a working connection is expected to be found |
4664 | +during the execution of regular Python client code: other states are for |
4665 | +internal usage and Python code should not rely on them. |
4666 | + |
4667 | +.. data:: STATUS_READY |
4668 | + |
4669 | + Connection established. No transaction in progress. |
4670 | + |
4671 | +.. data:: STATUS_BEGIN |
4672 | + |
4673 | + Connection established. A transaction is currently in progress. |
4674 | + |
4675 | +.. data:: STATUS_IN_TRANSACTION |
4676 | + |
4677 | + An alias for `STATUS_BEGIN` |
4678 | + |
4679 | + |
4680 | + |
4681 | +.. index:: |
4682 | + pair: Poll status; Constants |
4683 | + |
4684 | +.. _poll-constants: |
4685 | + |
4686 | +Poll constants |
4687 | +-------------- |
4688 | + |
4689 | +.. versionadded:: 2.2.0 |
4690 | + |
4691 | +These values can be returned by `connection.poll()` during asynchronous |
4692 | +connection and communication. They match the values in the libpq enum |
4693 | +`!PostgresPollingStatusType`. See :ref:`async-support` and |
4694 | +:ref:`green-support`. |
4695 | + |
4696 | +.. data:: POLL_OK |
4697 | + |
4698 | + The data being read is available, or the file descriptor is ready for |
4699 | + writing: reading or writing will not block. |
4700 | + |
4701 | +.. data:: POLL_READ |
4702 | + |
4703 | + Some data is being read from the backend, but it is not available yet on |
4704 | + the client and reading would block. Upon receiving this value, the client |
4705 | + should wait for the connection file descriptor to be ready *for reading*. |
4706 | + For example:: |
4707 | + |
4708 | + select.select([conn.fileno()], [], []) |
4709 | + |
4710 | +.. data:: POLL_WRITE |
4711 | + |
4712 | + Some data is being sent to the backend but the connection file descriptor |
4713 | + can't currently accept new data. Upon receiving this value, the client |
4714 | + should wait for the connection file descriptor to be ready *for writing*. |
4715 | + For example:: |
4716 | + |
4717 | + select.select([], [conn.fileno()], []) |
4718 | + |
4719 | +.. data:: POLL_ERROR |
4720 | + |
4721 | + There was a problem during connection polling. This value should actually |
4722 | + never be returned: in case of poll error usually an exception containing |
4723 | + the relevant details is raised. |
4724 | + |
4725 | + |
4726 | + |
4727 | +Additional database types |
4728 | +------------------------- |
4729 | + |
4730 | +The `!extensions` module includes typecasters for many standard |
4731 | +PostgreSQL types. These objects allow the conversion of returned data into |
4732 | +Python objects. All the typecasters are automatically registered, except |
4733 | +`UNICODE` and `UNICODEARRAY`: you can register them using |
4734 | +`register_type()` in order to receive Unicode objects instead of strings |
4735 | +from the database. See :ref:`unicode-handling` for details. |
4736 | + |
4737 | +.. data:: BOOLEAN |
4738 | + DATE |
4739 | + DECIMAL |
4740 | + FLOAT |
4741 | + INTEGER |
4742 | + INTERVAL |
4743 | + LONGINTEGER |
4744 | + TIME |
4745 | + UNICODE |
4746 | + |
4747 | + Typecasters for basic types. Notice that a few other ones (`~psycopg2.BINARY`, |
4748 | + `~psycopg2.DATETIME`, `~psycopg2.NUMBER`, `~psycopg2.ROWID`, |
4749 | + `~psycopg2.STRING`) are exposed by the `psycopg2` module for |DBAPI|_ |
4750 | + compliance. |
4751 | + |
4752 | +.. data:: BINARYARRAY |
4753 | + BOOLEANARRAY |
4754 | + DATEARRAY |
4755 | + DATETIMEARRAY |
4756 | + DECIMALARRAY |
4757 | + FLOATARRAY |
4758 | + INTEGERARRAY |
4759 | + INTERVALARRAY |
4760 | + LONGINTEGERARRAY |
4761 | + ROWIDARRAY |
4762 | + STRINGARRAY |
4763 | + TIMEARRAY |
4764 | + UNICODEARRAY |
4765 | + |
4766 | + Typecasters to convert arrays of sql types into Python lists. |
4767 | + |
4768 | +.. data:: PYDATE |
4769 | + PYDATETIME |
4770 | + PYINTERVAL |
4771 | + PYTIME |
4772 | + PYDATEARRAY |
4773 | + PYDATETIMEARRAY |
4774 | + PYINTERVALARRAY |
4775 | + PYTIMEARRAY |
4776 | + |
4777 | + Typecasters to convert time-related data types to Python `!datetime` |
4778 | + objects. |
4779 | + |
4780 | +.. data:: MXDATE |
4781 | + MXDATETIME |
4782 | + MXINTERVAL |
4783 | + MXTIME |
4784 | + MXDATEARRAY |
4785 | + MXDATETIMEARRAY |
4786 | + MXINTERVALARRAY |
4787 | + MXTIMEARRAY |
4788 | + |
4789 | + Typecasters to convert time-related data types to `mx.DateTime`_ objects. |
4790 | + Only available if Psycopg was compiled with `!mx` support. |
4791 | + |
4792 | +.. versionchanged:: 2.2.0 |
4793 | + previously the `DECIMAL` typecaster and the specific time-related |
4794 | + typecasters (`!PY*` and `!MX*`) were not exposed by the `extensions` |
4795 | + module. In older versions they can be imported from the implementation |
4796 | + module `!psycopg2._psycopg`. |
4797 | + |
4798 | |
4799 | === added file 'doc/html/_sources/extras.txt' |
4800 | --- doc/html/_sources/extras.txt 1970-01-01 00:00:00 +0000 |
4801 | +++ doc/html/_sources/extras.txt 2010-07-28 20:35:51 +0000 |
4802 | @@ -0,0 +1,165 @@ |
4803 | +`psycopg2.extras` -- Miscellaneous goodies for Psycopg 2 |
4804 | +============================================================= |
4805 | + |
4806 | +.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com> |
4807 | + |
4808 | +.. module:: psycopg2.extras |
4809 | + |
4810 | +.. testsetup:: |
4811 | + |
4812 | + import psycopg2.extras |
4813 | + from psycopg2.extras import Inet |
4814 | + |
4815 | + create_test_table() |
4816 | + |
4817 | +This module is a generic place used to hold little helper functions and |
4818 | +classes until a better place in the distribution is found. |
4819 | + |
4820 | + |
4821 | +.. index:: |
4822 | + pair: Cursor; Dictionary |
4823 | + |
4824 | +.. _dict-cursor: |
4825 | + |
4826 | +Dictionary-like cursor |
4827 | +---------------------- |
4828 | + |
4829 | +The dict cursors allow to access to the retrieved records using an iterface |
4830 | +similar to the Python dictionaries instead of the tuples. You can use it |
4831 | +either passing `DictConnection` as `connection_factory` argument |
4832 | +to the `~psycopg2.connect()` function or passing `DictCursor` as |
4833 | +the `!cursor_factory` argument to the `~connection.cursor()` method |
4834 | +of a regular `connection`. |
4835 | + |
4836 | + >>> dict_cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) |
4837 | + >>> dict_cur.execute("INSERT INTO test (num, data) VALUES(%s, %s)", |
4838 | + ... (100, "abc'def")) |
4839 | + >>> dict_cur.execute("SELECT * FROM test") |
4840 | + >>> rec = dict_cur.fetchone() |
4841 | + >>> rec['id'] |
4842 | + 1 |
4843 | + >>> rec['num'] |
4844 | + 100 |
4845 | + >>> rec['data'] |
4846 | + "abc'def" |
4847 | + |
4848 | +The records still support indexing as the original tuple: |
4849 | + |
4850 | + >>> rec[2] |
4851 | + "abc'def" |
4852 | + |
4853 | + |
4854 | +.. autoclass:: DictCursor |
4855 | + |
4856 | +.. autoclass:: DictConnection |
4857 | + |
4858 | +.. autoclass:: DictRow |
4859 | + |
4860 | + |
4861 | +Real dictionary cursor |
4862 | +^^^^^^^^^^^^^^^^^^^^^^ |
4863 | + |
4864 | +.. autoclass:: RealDictCursor |
4865 | + |
4866 | +.. autoclass:: RealDictConnection |
4867 | + |
4868 | +.. autoclass:: RealDictRow |
4869 | + |
4870 | + |
4871 | + |
4872 | +.. index:: |
4873 | + pair: Cursor; Logging |
4874 | + |
4875 | +Logging cursor |
4876 | +-------------- |
4877 | + |
4878 | +.. autoclass:: LoggingConnection |
4879 | + :members: initialize,filter |
4880 | + |
4881 | +.. autoclass:: LoggingCursor |
4882 | + |
4883 | + |
4884 | +.. autoclass:: MinTimeLoggingConnection |
4885 | + :members: initialize,filter |
4886 | + |
4887 | +.. autoclass:: MinTimeLoggingCursor |
4888 | + |
4889 | + |
4890 | + |
4891 | +.. index:: |
4892 | + pair: UUID; Data types |
4893 | + |
4894 | +UUID data type |
4895 | +-------------- |
4896 | + |
4897 | +.. versionadded:: 2.0.9 |
4898 | +.. versionchanged:: 2.0.13 added UUID array support. |
4899 | + |
4900 | +.. doctest:: |
4901 | + |
4902 | + >>> psycopg2.extras.register_uuid() |
4903 | + <psycopg2._psycopg.type object at 0x...> |
4904 | + |
4905 | + >>> # Python UUID can be used in SQL queries |
4906 | + >>> import uuid |
4907 | + >>> my_uuid = uuid.UUID('{12345678-1234-5678-1234-567812345678}') |
4908 | + >>> psycopg2.extensions.adapt(my_uuid).getquoted() |
4909 | + "'12345678-1234-5678-1234-567812345678'::uuid" |
4910 | + |
4911 | + >>> # PostgreSQL UUID are transformed into Python UUID objects. |
4912 | + >>> cur.execute("SELECT 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid") |
4913 | + >>> cur.fetchone()[0] |
4914 | + UUID('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11') |
4915 | + |
4916 | + |
4917 | +.. autofunction:: register_uuid |
4918 | + |
4919 | +.. autoclass:: UUID_adapter |
4920 | + |
4921 | + |
4922 | + |
4923 | +.. index:: |
4924 | + pair: INET; Data types |
4925 | + |
4926 | +:sql:`inet` data type |
4927 | +---------------------- |
4928 | + |
4929 | +.. versionadded:: 2.0.9 |
4930 | + |
4931 | +.. doctest:: |
4932 | + |
4933 | + >>> psycopg2.extras.register_inet() |
4934 | + <psycopg2._psycopg.type object at 0x...> |
4935 | + |
4936 | + >>> cur.mogrify("SELECT %s", (Inet('127.0.0.1/32'),)) |
4937 | + "SELECT E'127.0.0.1/32'::inet" |
4938 | + |
4939 | + >>> cur.execute("SELECT '192.168.0.1/24'::inet") |
4940 | + >>> cur.fetchone()[0].addr |
4941 | + '192.168.0.1/24' |
4942 | + |
4943 | + |
4944 | +.. autofunction:: register_inet() |
4945 | + |
4946 | +.. autoclass:: Inet |
4947 | + |
4948 | + |
4949 | + |
4950 | +.. index:: |
4951 | + single: Time zones; Fractional |
4952 | + |
4953 | +Fractional time zones |
4954 | +--------------------- |
4955 | + |
4956 | +.. autofunction:: register_tstz_w_secs |
4957 | + |
4958 | + .. versionadded:: 2.0.9 |
4959 | + |
4960 | +.. index:: |
4961 | + pair: Example; Coroutine; |
4962 | + |
4963 | +Coroutine support |
4964 | +----------------- |
4965 | + |
4966 | +.. autofunction:: wait_select(conn) |
4967 | + |
4968 | |
4969 | === added file 'doc/html/_sources/faq.txt' |
4970 | --- doc/html/_sources/faq.txt 1970-01-01 00:00:00 +0000 |
4971 | +++ doc/html/_sources/faq.txt 2010-07-28 20:35:51 +0000 |
4972 | @@ -0,0 +1,139 @@ |
4973 | +Frequently Asked Questions |
4974 | +========================== |
4975 | + |
4976 | +.. sectionauthor:: Daniele Varrazzo <daniele.varrazzo@gmail.com> |
4977 | + |
4978 | +Here are a few gotchas you may encounter using `psycopg2`. Feel free to |
4979 | +suggest new entries! |
4980 | + |
4981 | + |
4982 | +Problems with transactions handling |
4983 | +----------------------------------- |
4984 | + |
4985 | +.. cssclass:: faq |
4986 | + |
4987 | +Why does `!psycopg2` leave database sessions "idle in transaction"? |
4988 | + Psycopg normally starts a new transaction the first time a query is |
4989 | + executed, e.g. calling `cursor.execute()`, even if the command is a |
4990 | + :sql:`SELECT`. The transaction is not closed until an explicit |
4991 | + `~connection.commit()` or `~connection.rollback()`. |
4992 | + |
4993 | + If you are writing a long-living program, you should probably ensure to |
4994 | + call one of the transaction closing methods before leaving the connection |
4995 | + unused for a long time (which may also be a few seconds, depending on the |
4996 | + concurrency level in your database). Alternatively you can use a |
4997 | + connection in :ref:`autocommit <autocommit>` mode to avoid a new |
4998 | + transaction to be started at the first command. |
4999 | + |
5000 | +I 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.
Good work!