From 1461f88eb70ea3b438b43a5d0c655ade9de823cf Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Wed, 26 Jul 2017 16:41:51 +0000 Subject: [PATCH 01/26] Create branch for 5.0.x bugfix releases Work on 5.1 continues in the trunk From dac9306b787379ca541d7a124dbff5e51f2cf183 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 28 Jul 2017 11:31:07 +0000 Subject: [PATCH 02/26] Fix test issue with Pg 9.6 --- tests/test_classic_connection.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_classic_connection.py b/tests/test_classic_connection.py index bd449fad..2a8da49f 100755 --- a/tests/test_classic_connection.py +++ b/tests/test_classic_connection.py @@ -139,9 +139,12 @@ def testAttributeError(self): @unittest.skipIf(do_not_ask_for_host, do_not_ask_for_host_reason) def testAttributeHost(self): - def_host = 'localhost' + if dbhost and not dbhost.startswith('/'): + host = dbhost + else: + host = 'localhost' self.assertIsInstance(self.connection.host, str) - self.assertEqual(self.connection.host, dbhost or def_host) + self.assertEqual(self.connection.host, host) def testAttributeOptions(self): no_options = '' From 09fc3a25c7d7c3a20cfffbff7b5ba12e88307e86 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 24 Nov 2017 18:57:45 +0000 Subject: [PATCH 03/26] Fix the license entry in the setup file PyGreSQL is licensed under the PostgreSQL license (see LICENSE.txt) and not the Python Software Foundation license. --- LICENSE.txt | 3 +++ setup.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 298aadfb..6e442db6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -7,6 +7,9 @@ Copyright (c) 1995, Pascal Andre Further modifications copyright (c) 1997-2008 by D'Arcy J.M. Cain (darcy@PyGreSQL.org) +PyGreSQL is released under the PostgreSQL License, a liberal Open Source +license, similar to the BSD or MIT licenses: + Further modifications copyright (c) 2009-2017 by the PyGreSQL team. Permission to use, copy, modify, and distribute this software and its diff --git a/setup.py b/setup.py index 62029825..6309805f 100755 --- a/setup.py +++ b/setup.py @@ -180,7 +180,7 @@ def finalize_options(self): url="http://www.pygresql.org", download_url="http://www.pygresql.org/download/", platforms=["any"], - license="Python", + license="PostgreSQL", py_modules=py_modules, ext_modules=[Extension('_pg', c_sources, include_dirs=include_dirs, library_dirs=library_dirs, @@ -192,7 +192,7 @@ def finalize_options(self): classifiers=[ "Development Status :: 6 - Mature", "Intended Audience :: Developers", - "License :: OSI Approved :: Python Software Foundation License", + "License :: OSI Approved :: The PostgreSQL License", "Operating System :: OS Independent", "Programming Language :: C", 'Programming Language :: Python', From 497a06a0377a373a41c69a25508254bfc1638c24 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Mon, 22 Jan 2018 08:21:18 +0000 Subject: [PATCH 04/26] Use-after-free bug in query function implementation --- docs/contents/changelog.rst | 7 ++++++- pgmodule.c | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index 83f73c38..bdd0ce64 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -1,8 +1,13 @@ ChangeLog ========= -Version 5.0.4 (2017-07-23) +Version 5.0.5 (to be released) ------------------------------ +- The memory for the string with the number of rows affected by a classic pg + module query() was already freed (bug report and fix by Peifeng Qiu). + +Version 5.0.4 (2017-07-23) +-------------------------- - This version officially supports the new Python 3.6 and PostgreSQL 9.6. - query_formatted() can now be used without parameters. - The automatic renaming of columns that are invalid as field names of diff --git a/pgmodule.c b/pgmodule.c index c25b5776..ec7ca6f3 100644 --- a/pgmodule.c +++ b/pgmodule.c @@ -2338,11 +2338,13 @@ connQuery(connObject *self, PyObject *args) { char *ret = PQcmdTuples(result); - PQclear(result); if (ret[0]) /* return number of rows affected */ { - return PyStr_FromString(ret); + PyObject *obj = PyStr_FromString(ret); + PQclear(result); + return obj; } + PQclear(result); Py_INCREF(Py_None); return Py_None; } From 1de4b7ae66fba33184d95079218d4aa3862d79fe Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Mon, 22 Jan 2018 08:32:43 +0000 Subject: [PATCH 05/26] Fix test issue with Pg 9.6 --- tests/test_classic_dbwrapper.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_classic_dbwrapper.py b/tests/test_classic_dbwrapper.py index 71404d02..c93c3e80 100755 --- a/tests/test_classic_dbwrapper.py +++ b/tests/test_classic_dbwrapper.py @@ -244,11 +244,13 @@ def testAttributeError(self): @unittest.skipIf(do_not_ask_for_host, do_not_ask_for_host_reason) def testAttributeHost(self): - def_host = 'localhost' - host = self.db.host - self.assertIsInstance(host, str) - self.assertEqual(host, dbhost or def_host) - self.assertEqual(host, self.db.db.host) + if dbhost and not dbhost.startswith('/'): + host = dbhost + else: + host = 'localhost' + self.assertIsInstance(self.db.host, str) + self.assertEqual(self.db.host, host) + self.assertEqual(self.db.db.host, host) def testAttributeOptions(self): no_options = '' From 513e206f275cac5b6c0c3951844c0278217e5e83 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Mon, 22 Jan 2018 08:55:50 +0000 Subject: [PATCH 06/26] Adapt tests for Postgres 10 --- tests/test_classic_connection.py | 2 +- tests/test_classic_dbwrapper.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_classic_connection.py b/tests/test_classic_connection.py index 2a8da49f..4726a590 100755 --- a/tests/test_classic_connection.py +++ b/tests/test_classic_connection.py @@ -163,7 +163,7 @@ def testAttributeProtocolVersion(self): def testAttributeServerVersion(self): server_version = self.connection.server_version self.assertIsInstance(server_version, int) - self.assertTrue(70400 <= server_version < 100000) + self.assertTrue(90000 <= server_version < 110000) def testAttributeStatus(self): status_ok = 1 diff --git a/tests/test_classic_dbwrapper.py b/tests/test_classic_dbwrapper.py index c93c3e80..05dd4ef2 100755 --- a/tests/test_classic_dbwrapper.py +++ b/tests/test_classic_dbwrapper.py @@ -274,7 +274,7 @@ def testAttributeProtocolVersion(self): def testAttributeServerVersion(self): server_version = self.db.server_version self.assertIsInstance(server_version, int) - self.assertTrue(70400 <= server_version < 100000) + self.assertTrue(90000 <= server_version < 110000) self.assertEqual(server_version, self.db.db.server_version) def testAttributeStatus(self): From 90603e2fabce7edfa4ee254d4a4f13b112087cbe Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Mon, 22 Jan 2018 09:15:34 +0000 Subject: [PATCH 07/26] Fix sort order in test to make it reliable --- tests/test_dbapi20.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_dbapi20.py b/tests/test_dbapi20.py index c76744cc..926bc8ce 100755 --- a/tests/test_dbapi20.py +++ b/tests/test_dbapi20.py @@ -439,7 +439,7 @@ def test_type_cache_typecast(self): def test_cursor_iteration(self): con = self._connect() cur = con.cursor() - cur.execute("select 1 union select 2 union select 3") + cur.execute("select 1 union select 2 union select 3 order by 1") self.assertEqual([r[0] for r in cur], [1, 2, 3]) def test_cursor_invalidation(self): From 2b2d5b6c97a3f100a13ab0a8f7f03282c0c51534 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Mon, 22 Jan 2018 09:44:28 +0000 Subject: [PATCH 08/26] Update year, version number and supported Pg versions --- LICENSE.txt | 4 ++-- docs/about.txt | 9 +++++---- docs/announce.rst | 12 ++++++------ docs/conf.py | 4 ++-- docs/contents/changelog.rst | 1 + docs/contents/install.rst | 2 +- docs/contents/pg/adaptation.rst | 4 ++-- docs/copyright.rst | 2 +- docs/download/download.rst | 10 +++++----- mktar | 2 +- pg.py | 2 +- pgmodule.c | 4 ++-- setup.py | 7 ++++--- 13 files changed, 33 insertions(+), 30 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 6e442db6..71b4db02 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -7,11 +7,11 @@ Copyright (c) 1995, Pascal Andre Further modifications copyright (c) 1997-2008 by D'Arcy J.M. Cain (darcy@PyGreSQL.org) +Further modifications copyright (c) 2009-2018 by the PyGreSQL team. + PyGreSQL is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses: -Further modifications copyright (c) 2009-2017 by the PyGreSQL team. - Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this diff --git a/docs/about.txt b/docs/about.txt index 4baefe33..08952ba2 100644 --- a/docs/about.txt +++ b/docs/about.txt @@ -5,7 +5,7 @@ PostgreSQL features from a Python script. | This software is copyright © 1995, Pascal Andre. | Further modifications are copyright © 1997-2008 by D'Arcy J.M. Cain. - | Further modifications are copyright © 2009-2017 by the PyGreSQL team. + | Further modifications are copyright © 2009-2018 by the PyGreSQL team. | For licensing details, see the full :doc:`copyright`. **PostgreSQL** is a highly scalable, SQL compliant, open source @@ -36,6 +36,7 @@ on the PyGres95 code written by Pascal Andre (andre@chimay.via.ecp.fr). D'Arcy (darcy@druid.net) renamed it to PyGreSQL starting with version 2.0 and serves as the "BDFL" of PyGreSQL. -The current version PyGreSQL 5.0.4 needs PostgreSQL 9.0 or newer and Python 2.6, -2.7 or 3.3 to 3.5. If you need to support older PostgreSQL versions or older -Python 2.x versions, you can resort to PyGreSQL 4.x that still supports them. +The current version PyGreSQL 5.0.5 needs PostgreSQL 9.0 to 9.6 or 10, and +Python 2.6, 2.7 or 3.3 to 3.6. If you need to support older PostgreSQL versions +or older Python 2.x versions, you can resort to the PyGreSQL 4.x versions that +still support them. diff --git a/docs/announce.rst b/docs/announce.rst index b4910878..c5096a7c 100644 --- a/docs/announce.rst +++ b/docs/announce.rst @@ -3,12 +3,12 @@ PyGreSQL Announcements ====================== --------------------------------- -Release of PyGreSQL version 5.0.4 +Release of PyGreSQL version 5.0.5 --------------------------------- -Release 5.0.4 of PyGreSQL. +Release 5.0.5 of PyGreSQL. -It is available at: http://pygresql.org/files/PyGreSQL-5.0.4.tar.gz. +It is available at: http://pygresql.org/files/PyGreSQL-5.0.5.tar.gz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection. @@ -24,9 +24,9 @@ This version has been built and unit tested on: - FreeBSD - openSUSE - Ubuntu - - Windows 7 with both MinGW and Visual Studio - - PostgreSQL 9.0 to 9.6 32 and 64bit - - Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6 32 and 64bit + - Windows 7 and 10 with both MinGW and Visual Studio + - PostgreSQL 9.0 to 9.6 and 10 (32 and 64bit) + - Python 2.6, 2.7 and 3.3 to 3.6 (32 and 64bit) | D'Arcy J.M. Cain | darcy@PyGreSQL.org diff --git a/docs/conf.py b/docs/conf.py index ff61ee54..9bc41dcc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -61,7 +61,7 @@ # General information about the project. project = 'PyGreSQL' author = 'The PyGreSQL team' -copyright = '2017, ' + author +copyright = '2018, ' + author # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -70,7 +70,7 @@ # The short X.Y version. version = '5.0' # The full version, including alpha/beta/rc tags. -release = '5.0.4' +release = '5.0.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index bdd0ce64..f93c0355 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -3,6 +3,7 @@ ChangeLog Version 5.0.5 (to be released) ------------------------------ +- This version officially supports the new PostgreSQL 10. - The memory for the string with the number of rows affected by a classic pg module query() was already freed (bug report and fix by Peifeng Qiu). diff --git a/docs/contents/install.rst b/docs/contents/install.rst index db1b3d0b..e99df890 100644 --- a/docs/contents/install.rst +++ b/docs/contents/install.rst @@ -11,7 +11,7 @@ are on Windows, make sure that the directory with libpq.dll is in your ``PATH`` environment variable. The current version of PyGreSQL has been tested with Python versions -2.6, 2.7, 3.3 to 3.6 and PostGreSQL version 9.0 to 9.6. +2.6, 2.7 and 3.3 to 3.6, and PostGreSQL versions 9.0 to 9.6 and 10. PyGreSQL will be installed as three modules, a dynamic module called _pg.pyd, and two pure Python wrapper modules called pg.py and pgdb.py. diff --git a/docs/contents/pg/adaptation.rst b/docs/contents/pg/adaptation.rst index a5a9b0a1..4611ebba 100644 --- a/docs/contents/pg/adaptation.rst +++ b/docs/contents/pg/adaptation.rst @@ -363,8 +363,8 @@ With PostgreSQL we can easily calculate that these two circles overlap:: True However, calculating the intersection points between the two circles using the -``#`` operator does not work (at least not as of PostgreSQL version 9.6). -So let' resort to SymPy to find out. To ease importing circles from +``#`` operator does not work (at least not as of PostgreSQL version 10). +So let's resort to SymPy to find out. To ease importing circles from PostgreSQL to SymPy, we create and register the following typecast function:: >>> from sympy import Point, Circle diff --git a/docs/copyright.rst b/docs/copyright.rst index 16072476..4283ed43 100644 --- a/docs/copyright.rst +++ b/docs/copyright.rst @@ -10,7 +10,7 @@ Copyright (c) 1995, Pascal Andre Further modifications copyright (c) 1997-2008 by D'Arcy J.M. Cain (darcy@PyGreSQL.org) -Further modifications copyright (c) 2009-2017 by the PyGreSQL team. +Further modifications copyright (c) 2009-2018 by the PyGreSQL team. Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement diff --git a/docs/download/download.rst b/docs/download/download.rst index ac6df827..af712567 100644 --- a/docs/download/download.rst +++ b/docs/download/download.rst @@ -17,11 +17,11 @@ A **FreeBSD package** is available in their ports collection An **openSUSE package** is available through their build service at * https://software.opensuse.org/package/PyGreSQL?search_term=pygresql A **Win32 installer** for various Python versions is available at - * http://pygresql.org/files/PyGreSQL-5.0.4.win-amd64-py2.6.exe - * http://pygresql.org/files/PyGreSQL-5.0.4.win-amd64-py2.7.exe - * http://pygresql.org/files/PyGreSQL-5.0.4.win-amd64-py3.4.exe - * http://pygresql.org/files/PyGreSQL-5.0.4.win-amd64-py3.5.exe - * http://pygresql.org/files/PyGreSQL-5.0.4.win-amd64-py3.6.exe + * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py2.6.exe + * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py2.7.exe + * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py3.4.exe + * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py3.5.exe + * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py3.6.exe Older PyGreSQL versions ----------------------- diff --git a/mktar b/mktar index 4a2c2b37..f73ef7f3 100755 --- a/mktar +++ b/mktar @@ -1,6 +1,6 @@ #! /bin/sh -VERSION=5.0.4 +VERSION=5.0.5 DISTDIR=/u/WEB/pyg/files # some safety tests diff --git a/pg.py b/pg.py index 8c7848a5..e830a668 100644 --- a/pg.py +++ b/pg.py @@ -14,7 +14,7 @@ For a DB-API 2 compliant interface use the newer pgdb module. """ -# Copyright (c) 1997-2017 by D'Arcy J.M. Cain. +# Copyright (c) 1997-2018 by D'Arcy J.M. Cain. # # Contributions made by Ch. Zwerschke and others. # diff --git a/pgmodule.c b/pgmodule.c index ec7ca6f3..3df18eb4 100644 --- a/pgmodule.c +++ b/pgmodule.c @@ -22,7 +22,7 @@ * AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, * ENHANCEMENTS, OR MODIFICATIONS. * - * Further modifications copyright 1997 to 2017 by D'Arcy J.M. Cain + * Further modifications copyright 1997 to 2018 by D'Arcy J.M. Cain * (darcy@PyGreSQL.org) subject to the same terms and conditions as above. * */ @@ -3488,7 +3488,7 @@ connGetAttr(connObject *self, PyObject *nameobj) if (!strcmp(name, "host")) { char *r = PQhost(self->cnx); - if (!r || r[0] == '/') /* Pg 9.6 can return a Unix socket path */ + if (!r || r[0] == '/') /* Pg >= 9.6 can return a Unix socket path */ r = "localhost"; return PyStr_FromString(r); } diff --git a/setup.py b/setup.py index 6309805f..382d75a7 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #! /usr/bin/python # $Id$ -"""Setup script for PyGreSQL version 5.0.4 +"""Setup script for PyGreSQL version 5.0.5 PyGreSQL is an open-source Python module that interfaces to a PostgreSQL database. It embeds the PostgreSQL query library to allow @@ -13,7 +13,7 @@ * setup script created 2000 by Mark Alexander * improved 2000 by Jeremy Hylton * improved 2001 by Gerhard Haering -* improved 2006 to 2017 by Christoph Zwerschke +* improved 2006 to 2018 by Christoph Zwerschke Prerequisites to be installed: * Python including devel package (header files and distutils) @@ -21,7 +21,8 @@ * PostgreSQL pg_config tool (usually included in the devel package) (the Windows installer has it as part of the database server feature) -The supported versions are Python 2.6-2.7, 3.3-3.6 and PostgreSQL 9.0-9.6. +PyGreSQL currently supports Python versions 2.6, 2.7 and 3.3 to 3.6, +and PostgreSQL versions 9.0 to 9.6 and 10. Use as follows: python setup.py build # to build the module From bb63c84a84e9f440fdf2dfa00fec4a2c4b4940bd Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Sun, 22 Apr 2018 18:16:20 +0000 Subject: [PATCH 09/26] Backport patch for Python 3.7 to the 5.0 branch --- pgmodule.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pgmodule.c b/pgmodule.c index 3df18eb4..08ed188d 100644 --- a/pgmodule.c +++ b/pgmodule.c @@ -2224,14 +2224,14 @@ connQuery(connObject *self, PyObject *args) { /* prepare arguments */ PyObject **str, **s; - char **parms, **p; + const char **parms, **p; register int i; str = (PyObject **)PyMem_Malloc(nparms * sizeof(*str)); - parms = (char **)PyMem_Malloc(nparms * sizeof(*parms)); + parms = (const char **)PyMem_Malloc(nparms * sizeof(*parms)); if (!str || !parms) { - PyMem_Free(parms); PyMem_Free(str); + PyMem_Free((void *)parms); PyMem_Free(str); Py_XDECREF(query_obj); Py_XDECREF(param_obj); return PyErr_NoMemory(); } @@ -2256,7 +2256,7 @@ connQuery(connObject *self, PyObject *args) PyObject *str_obj = get_encoded_string(obj, encoding); if (!str_obj) { - PyMem_Free(parms); + PyMem_Free((void *)parms); while (s != str) { s--; Py_DECREF(*s); } PyMem_Free(str); Py_XDECREF(query_obj); @@ -2272,7 +2272,7 @@ connQuery(connObject *self, PyObject *args) PyObject *str_obj = PyObject_Str(obj); if (!str_obj) { - PyMem_Free(parms); + PyMem_Free((void *)parms); while (s != str) { s--; Py_DECREF(*s); } PyMem_Free(str); Py_XDECREF(query_obj); @@ -2288,10 +2288,10 @@ connQuery(connObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS result = PQexecParams(self->cnx, query, nparms, - NULL, (const char * const *)parms, NULL, NULL, 0); + NULL, parms, NULL, NULL, 0); Py_END_ALLOW_THREADS - PyMem_Free(parms); + PyMem_Free((void *)parms); while (s != str) { s--; Py_DECREF(*s); } PyMem_Free(str); } From e977c928e58842b88fefe258ab819245e8408eba Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Mon, 23 Apr 2018 12:42:23 +0000 Subject: [PATCH 10/26] Fix typo in docs --- docs/contents/pgdb/cursor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contents/pgdb/cursor.rst b/docs/contents/pgdb/cursor.rst index 307d7098..6476f14a 100644 --- a/docs/contents/pgdb/cursor.rst +++ b/docs/contents/pgdb/cursor.rst @@ -55,7 +55,7 @@ rowcount -- number of rows of the result :meth:`Cursor.execute` or :meth:`Cursor.executemany` call produced (for DQL statements like SELECT) or affected (for DML statements like UPDATE or INSERT). It is also set by the :meth:`Cursor.copy_from` and - :meth':`Cursor.copy_to` methods. The attribute is -1 in case no such + :meth:`Cursor.copy_to` methods. The attribute is -1 in case no such method call has been performed on the cursor or the rowcount of the last operation cannot be determined by the interface. From 2fb948ed6f5c6a72d086b33ef0f37cb0dc000181 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Wed, 23 May 2018 17:36:31 +0000 Subject: [PATCH 11/26] Adapt Trove classifier for the PostgreSQL license Has been added simply as "PostgreSQL License" (https://github.com/pypa/warehouse/issues/3843). --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 382d75a7..b1136f9e 100755 --- a/setup.py +++ b/setup.py @@ -193,7 +193,7 @@ def finalize_options(self): classifiers=[ "Development Status :: 6 - Mature", "Intended Audience :: Developers", - "License :: OSI Approved :: The PostgreSQL License", + "License :: OSI Approved :: PostgreSQL License", "Operating System :: OS Independent", "Programming Language :: C", 'Programming Language :: Python', From 82ee6287d63a7308762773c55c3cc134518905e1 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Sun, 8 Jul 2018 14:48:06 +0000 Subject: [PATCH 12/26] Prepare for version 5.0.6 --- docs/about.txt | 4 ++-- docs/announce.rst | 8 ++++---- docs/conf.py | 2 +- docs/contents/changelog.rst | 9 +++++++-- docs/contents/install.rst | 2 +- docs/download/download.rst | 11 ++++++----- mktar | 2 +- setup.py | 7 ++++--- tox.ini | 6 +++--- 9 files changed, 29 insertions(+), 22 deletions(-) diff --git a/docs/about.txt b/docs/about.txt index 08952ba2..009a6c2a 100644 --- a/docs/about.txt +++ b/docs/about.txt @@ -36,7 +36,7 @@ on the PyGres95 code written by Pascal Andre (andre@chimay.via.ecp.fr). D'Arcy (darcy@druid.net) renamed it to PyGreSQL starting with version 2.0 and serves as the "BDFL" of PyGreSQL. -The current version PyGreSQL 5.0.5 needs PostgreSQL 9.0 to 9.6 or 10, and -Python 2.6, 2.7 or 3.3 to 3.6. If you need to support older PostgreSQL versions +The current version PyGreSQL 5.0.6 needs PostgreSQL 9.0 to 9.6 or 10, and +Python 2.6, 2.7 or 3.3 to 3.7. If you need to support older PostgreSQL versions or older Python 2.x versions, you can resort to the PyGreSQL 4.x versions that still support them. diff --git a/docs/announce.rst b/docs/announce.rst index c5096a7c..ce24f1a0 100644 --- a/docs/announce.rst +++ b/docs/announce.rst @@ -3,12 +3,12 @@ PyGreSQL Announcements ====================== --------------------------------- -Release of PyGreSQL version 5.0.5 +Release of PyGreSQL version 5.0.6 --------------------------------- -Release 5.0.5 of PyGreSQL. +Release 5.0.6 of PyGreSQL. -It is available at: http://pygresql.org/files/PyGreSQL-5.0.5.tar.gz. +It is available at: http://pygresql.org/files/PyGreSQL-5.0.6.tar.gz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection. @@ -26,7 +26,7 @@ This version has been built and unit tested on: - Ubuntu - Windows 7 and 10 with both MinGW and Visual Studio - PostgreSQL 9.0 to 9.6 and 10 (32 and 64bit) - - Python 2.6, 2.7 and 3.3 to 3.6 (32 and 64bit) + - Python 2.6, 2.7 and 3.3 to 3.7 (32 and 64bit) | D'Arcy J.M. Cain | darcy@PyGreSQL.org diff --git a/docs/conf.py b/docs/conf.py index 9bc41dcc..a4949c37 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -70,7 +70,7 @@ # The short X.Y version. version = '5.0' # The full version, including alpha/beta/rc tags. -release = '5.0.5' +release = '5.0.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index f93c0355..e990a0fd 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -1,8 +1,13 @@ ChangeLog ========= -Version 5.0.5 (to be released) ------------------------------- +Vesion 5.0.6 (to be released) +----------------------------- +- This version officially supports the new Python 3.7. +- Correct trove classifier for the PostgreSQL License. + +Version 5.0.5 (2018-04-25) +-------------------------- - This version officially supports the new PostgreSQL 10. - The memory for the string with the number of rows affected by a classic pg module query() was already freed (bug report and fix by Peifeng Qiu). diff --git a/docs/contents/install.rst b/docs/contents/install.rst index e99df890..ac4f360d 100644 --- a/docs/contents/install.rst +++ b/docs/contents/install.rst @@ -11,7 +11,7 @@ are on Windows, make sure that the directory with libpq.dll is in your ``PATH`` environment variable. The current version of PyGreSQL has been tested with Python versions -2.6, 2.7 and 3.3 to 3.6, and PostGreSQL versions 9.0 to 9.6 and 10. +2.6, 2.7 and 3.3 to 3.7, and PostGreSQL versions 9.0 to 9.6 and 10. PyGreSQL will be installed as three modules, a dynamic module called _pg.pyd, and two pure Python wrapper modules called pg.py and pgdb.py. diff --git a/docs/download/download.rst b/docs/download/download.rst index af712567..b8e289a2 100644 --- a/docs/download/download.rst +++ b/docs/download/download.rst @@ -17,11 +17,12 @@ A **FreeBSD package** is available in their ports collection An **openSUSE package** is available through their build service at * https://software.opensuse.org/package/PyGreSQL?search_term=pygresql A **Win32 installer** for various Python versions is available at - * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py2.6.exe - * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py2.7.exe - * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py3.4.exe - * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py3.5.exe - * http://pygresql.org/files/PyGreSQL-5.0.5.win-amd64-py3.6.exe + * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py2.6.exe + * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py2.7.exe + * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.4.exe + * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.5.exe + * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.6.exe + * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.7.exe Older PyGreSQL versions ----------------------- diff --git a/mktar b/mktar index f73ef7f3..ae6f5e59 100755 --- a/mktar +++ b/mktar @@ -1,6 +1,6 @@ #! /bin/sh -VERSION=5.0.5 +VERSION=5.0.6 DISTDIR=/u/WEB/pyg/files # some safety tests diff --git a/setup.py b/setup.py index b1136f9e..292a376f 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #! /usr/bin/python # $Id$ -"""Setup script for PyGreSQL version 5.0.5 +"""Setup script for PyGreSQL version 5.0.6 PyGreSQL is an open-source Python module that interfaces to a PostgreSQL database. It embeds the PostgreSQL query library to allow @@ -21,7 +21,7 @@ * PostgreSQL pg_config tool (usually included in the devel package) (the Windows installer has it as part of the database server feature) -PyGreSQL currently supports Python versions 2.6, 2.7 and 3.3 to 3.6, +PyGreSQL currently supports Python versions 2.6, 2.7 and 3.3 to 3.7, and PostgreSQL versions 9.0 to 9.6 and 10. Use as follows: @@ -33,7 +33,7 @@ """ -version = '5.0.5' +version = '5.0.6' import sys @@ -205,6 +205,7 @@ def finalize_options(self): 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', "Programming Language :: SQL", "Topic :: Database", "Topic :: Database :: Front-Ends", diff --git a/tox.ini b/tox.ini index 17e52b3e..4f7252b2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,11 @@ -# config file for tox 2.0 +# config file for tox 2 [tox] -envlist = py{26,27,33,34,35,36} +envlist = py{26,27,33,34,35,36,37} [testenv] deps = py26: unittest2 commands = py26: unit2 discover [] - py{27,33,34,35,36}: python -m unittest discover [] + py{27,33,34,35,36,37}: python -m unittest discover [] From 8454d4fdaa64a11cc6dca6bd53f6b89f56ba3ef6 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Wed, 2 Jan 2019 19:14:41 +0000 Subject: [PATCH 13/26] Backport fixes in trunk to 5.0.x --- docs/community/mailinglist.rst | 2 +- docs/community/support.rst | 4 ++-- docs/contents/changelog.rst | 8 ++++++-- docs/contents/pg/adaptation.rst | 2 +- docs/contents/pgdb/cursor.rst | 2 +- pg.py | 4 ++-- pgdb.py | 4 ++-- pgmodule.c | 4 ++-- tests/test_classic_functions.py | 2 ++ 9 files changed, 19 insertions(+), 13 deletions(-) diff --git a/docs/community/mailinglist.rst b/docs/community/mailinglist.rst index c0269512..b39a308a 100644 --- a/docs/community/mailinglist.rst +++ b/docs/community/mailinglist.rst @@ -2,7 +2,7 @@ Mailing list ------------ You can join -`the mailing list `_ +`the mailing list `_ to discuss future development of the PyGreSQL interface or if you have questions or problems with PyGreSQL that are not covered in the :doc:`documentation <../contents/index>`. diff --git a/docs/community/support.rst b/docs/community/support.rst index ac4fa6e8..457bd8bd 100644 --- a/docs/community/support.rst +++ b/docs/community/support.rst @@ -8,11 +8,11 @@ Support see http://www.postgresql.org/support/ **PyGreSQL**: - Join `the PyGreSQL mailing list `_ + Join `the PyGreSQL mailing list `_ if you need help regarding PyGreSQL. Please also send context diffs there, if you would like to proposes changes. Please note that messages to individual developers will generally not be answered directly. All questions, comments and code changes must be - submitted to the mailing list for peer review and archiving purposes. \ No newline at end of file + submitted to the mailing list for peer review and archiving purposes. diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index e990a0fd..d3095df5 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -1,8 +1,12 @@ ChangeLog ========= -Vesion 5.0.6 (to be released) ------------------------------ +Vesion 5.0.7 (2019-mm-dd) +------------------------- +- Fixed a bug in parsing array subscript ranges (reported by Justin Pryzby). + +Vesion 5.0.6 (2018-07-29) +------------------------- - This version officially supports the new Python 3.7. - Correct trove classifier for the PostgreSQL License. diff --git a/docs/contents/pg/adaptation.rst b/docs/contents/pg/adaptation.rst index 4611ebba..c9534434 100644 --- a/docs/contents/pg/adaptation.rst +++ b/docs/contents/pg/adaptation.rst @@ -307,7 +307,7 @@ We can set a different typecast function for ``int4``, but it will not become effective, the C module continues to use its internal typecasting. However, we can add new typecast functions for the database types that are -not supported by the C modul. Fore example, we can create a typecast function +not supported by the C module. For example, we can create a typecast function that casts items of the composite PostgreSQL type used as example in the previous section to instances of the corresponding Python class. diff --git a/docs/contents/pgdb/cursor.rst b/docs/contents/pgdb/cursor.rst index 6476f14a..a2ac63e8 100644 --- a/docs/contents/pgdb/cursor.rst +++ b/docs/contents/pgdb/cursor.rst @@ -117,7 +117,7 @@ executemany -- execute many similar database operations Prepare a database operation (query or command) and then execute it against all parameter tuples or mappings found in the sequence *seq_of_parameters*. -Parameters are bounded to the query using Python extended format codes, +Parameters are bound to the query using Python extended format codes, e.g. ``" ... WHERE name=%(name)s"``. callproc -- Call a stored procedure diff --git a/pg.py b/pg.py index e830a668..c598cf4c 100644 --- a/pg.py +++ b/pg.py @@ -971,8 +971,8 @@ class Typecasts(dict): The cast functions get passed the string representation of a value in the database which they need to convert to a Python object. The - passed string will never be None since NULL values are already be - handled before the cast function is called. + passed string will never be None since NULL values are already handled + before the cast function is called. Note that the basic types are already handled by the C extension. They only need to be handled here as record or array components. diff --git a/pgdb.py b/pgdb.py index fe52df4a..8cd2662a 100644 --- a/pgdb.py +++ b/pgdb.py @@ -493,8 +493,8 @@ class Typecasts(dict): The cast functions get passed the string representation of a value in the database which they need to convert to a Python object. The - passed string will never be None since NULL values are already be - handled before the cast function is called. + passed string will never be None since NULL values are already handled + before the cast function is called. """ # the default cast functions diff --git a/pgmodule.c b/pgmodule.c index 08ed188d..b4feec81 100644 --- a/pgmodule.c +++ b/pgmodule.c @@ -664,11 +664,11 @@ cast_array(char *s, Py_ssize_t size, int encoding, if (s == end || *s++ != '[') break; while (s != end && *s == ' ') ++s; if (s != end && (*s == '+' || *s == '-')) ++s; - if (s == end || *s <= '0' || *s >= '9') break; + if (s == end || *s < '0' || *s > '9') break; while (s != end && *s >= '0' && *s <= '9') ++s; if (s == end || *s++ != ':') break; if (s != end && (*s == '+' || *s == '-')) ++s; - if (s == end || *s <= '0' || *s >= '9') break; + if (s == end || *s < '0' || *s > '9') break; while (s != end && *s >= '0' && *s <= '9') ++s; if (s == end || *s++ != ']') break; while (s != end && *s == ' ') ++s; diff --git a/tests/test_classic_functions.py b/tests/test_classic_functions.py index 284665cf..e168e6d2 100755 --- a/tests/test_classic_functions.py +++ b/tests/test_classic_functions.py @@ -202,6 +202,8 @@ class TestParseArray(unittest.TestCase): ('[-1:+1]={1,2,3}', int, [1, 2, 3]), ('[-3:-1]={1,2,3}', int, [1, 2, 3]), ('[+1:+3]={1,2,3}', int, [1, 2, 3]), + ('[0:2]={1,2,3}', int, [1, 2, 3]), + ('[7:9]={1,2,3}', int, [1, 2, 3]), ('[]={1,2,3}', int, ValueError), ('[1:]={1,2,3}', int, ValueError), ('[:3]={1,2,3}', int, ValueError), From 23514e695fe1497f8abcee5d08a58801645ac6be Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Wed, 2 Jan 2019 19:21:48 +0000 Subject: [PATCH 14/26] Update year of copyright --- LICENSE.txt | 2 +- docs/about.txt | 2 +- docs/conf.py | 2 +- docs/copyright.rst | 2 +- pg.py | 2 +- pgmodule.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 71b4db02..5d3cd86e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -7,7 +7,7 @@ Copyright (c) 1995, Pascal Andre Further modifications copyright (c) 1997-2008 by D'Arcy J.M. Cain (darcy@PyGreSQL.org) -Further modifications copyright (c) 2009-2018 by the PyGreSQL team. +Further modifications copyright (c) 2009-2019 by the PyGreSQL team. PyGreSQL is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses: diff --git a/docs/about.txt b/docs/about.txt index 009a6c2a..206e3984 100644 --- a/docs/about.txt +++ b/docs/about.txt @@ -5,7 +5,7 @@ PostgreSQL features from a Python script. | This software is copyright © 1995, Pascal Andre. | Further modifications are copyright © 1997-2008 by D'Arcy J.M. Cain. - | Further modifications are copyright © 2009-2018 by the PyGreSQL team. + | Further modifications are copyright © 2009-2019 by the PyGreSQL team. | For licensing details, see the full :doc:`copyright`. **PostgreSQL** is a highly scalable, SQL compliant, open source diff --git a/docs/conf.py b/docs/conf.py index a4949c37..e9f4eaa5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -61,7 +61,7 @@ # General information about the project. project = 'PyGreSQL' author = 'The PyGreSQL team' -copyright = '2018, ' + author +copyright = '2019, ' + author # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/copyright.rst b/docs/copyright.rst index 4283ed43..52d4a22a 100644 --- a/docs/copyright.rst +++ b/docs/copyright.rst @@ -10,7 +10,7 @@ Copyright (c) 1995, Pascal Andre Further modifications copyright (c) 1997-2008 by D'Arcy J.M. Cain (darcy@PyGreSQL.org) -Further modifications copyright (c) 2009-2018 by the PyGreSQL team. +Further modifications copyright (c) 2009-2019 by the PyGreSQL team. Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement diff --git a/pg.py b/pg.py index c598cf4c..23c4abae 100644 --- a/pg.py +++ b/pg.py @@ -14,7 +14,7 @@ For a DB-API 2 compliant interface use the newer pgdb module. """ -# Copyright (c) 1997-2018 by D'Arcy J.M. Cain. +# Copyright (c) 1997-2019 by D'Arcy J.M. Cain. # # Contributions made by Ch. Zwerschke and others. # diff --git a/pgmodule.c b/pgmodule.c index b4feec81..e70aaa39 100644 --- a/pgmodule.c +++ b/pgmodule.c @@ -22,7 +22,7 @@ * AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, * ENHANCEMENTS, OR MODIFICATIONS. * - * Further modifications copyright 1997 to 2018 by D'Arcy J.M. Cain + * Further modifications copyright 1997 to 2019 by D'Arcy J.M. Cain * (darcy@PyGreSQL.org) subject to the same terms and conditions as above. * */ From 2491fc57742e6eab246966688216b4968743bfcb Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 4 Jan 2019 17:20:28 +0000 Subject: [PATCH 15/26] Fix an issue with the parameter() method test --- tests/test_classic_connection.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_classic_connection.py b/tests/test_classic_connection.py index 4726a590..121f1dee 100755 --- a/tests/test_classic_connection.py +++ b/tests/test_classic_connection.py @@ -274,19 +274,19 @@ def testMethodParameter(self): self.assertRaises(TypeError, parameter) r = parameter('this server setting does not exist') self.assertIsNone(r) - s = query('show server_version').getresult()[0][0].upper() + s = query('show server_version').getresult()[0][0] self.assertIsNotNone(s) r = parameter('server_version') self.assertEqual(r, s) - s = query('show server_encoding').getresult()[0][0].upper() + s = query('show server_encoding').getresult()[0][0] self.assertIsNotNone(s) r = parameter('server_encoding') self.assertEqual(r, s) - s = query('show client_encoding').getresult()[0][0].upper() + s = query('show client_encoding').getresult()[0][0] self.assertIsNotNone(s) r = parameter('client_encoding') self.assertEqual(r, s) - s = query('show server_encoding').getresult()[0][0].upper() + s = query('show server_encoding').getresult()[0][0] self.assertIsNotNone(s) r = parameter('server_encoding') self.assertEqual(r, s) From 4deb05d36a8a11270be1caa6cd4acad819d07180 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 4 Jan 2019 17:49:21 +0000 Subject: [PATCH 16/26] Update version numbers --- docs/about.txt | 2 +- docs/announce.rst | 8 ++++---- docs/conf.py | 2 +- docs/contents/changelog.rst | 1 + docs/contents/general.rst | 2 +- docs/contents/install.rst | 2 +- docs/contents/pg/adaptation.rst | 2 +- docs/contents/pg/connection.rst | 10 +++++----- docs/contents/pg/module.rst | 4 ++-- docs/contents/pgdb/introduction.rst | 2 +- docs/download/download.rst | 12 ++++++------ mktar | 2 +- pg.py | 2 +- setup.py | 4 ++-- tests/test_classic_connection.py | 2 +- tests/test_classic_dbwrapper.py | 2 +- 16 files changed, 30 insertions(+), 29 deletions(-) diff --git a/docs/about.txt b/docs/about.txt index 206e3984..f4b8a57f 100644 --- a/docs/about.txt +++ b/docs/about.txt @@ -36,7 +36,7 @@ on the PyGres95 code written by Pascal Andre (andre@chimay.via.ecp.fr). D'Arcy (darcy@druid.net) renamed it to PyGreSQL starting with version 2.0 and serves as the "BDFL" of PyGreSQL. -The current version PyGreSQL 5.0.6 needs PostgreSQL 9.0 to 9.6 or 10, and +The current version PyGreSQL 5.0.7 needs PostgreSQL 9.0 to 9.6 or 10 or 11, and Python 2.6, 2.7 or 3.3 to 3.7. If you need to support older PostgreSQL versions or older Python 2.x versions, you can resort to the PyGreSQL 4.x versions that still support them. diff --git a/docs/announce.rst b/docs/announce.rst index ce24f1a0..ae71a1cb 100644 --- a/docs/announce.rst +++ b/docs/announce.rst @@ -3,12 +3,12 @@ PyGreSQL Announcements ====================== --------------------------------- -Release of PyGreSQL version 5.0.6 +Release of PyGreSQL version 5.0.7 --------------------------------- -Release 5.0.6 of PyGreSQL. +Release 5.0.7 of PyGreSQL. -It is available at: http://pygresql.org/files/PyGreSQL-5.0.6.tar.gz. +It is available at: http://pygresql.org/files/PyGreSQL-5.0.7.tar.gz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection. @@ -25,7 +25,7 @@ This version has been built and unit tested on: - openSUSE - Ubuntu - Windows 7 and 10 with both MinGW and Visual Studio - - PostgreSQL 9.0 to 9.6 and 10 (32 and 64bit) + - PostgreSQL 9.0 to 9.6 and 10 or 11 (32 and 64bit) - Python 2.6, 2.7 and 3.3 to 3.7 (32 and 64bit) | D'Arcy J.M. Cain diff --git a/docs/conf.py b/docs/conf.py index e9f4eaa5..89d99a12 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -70,7 +70,7 @@ # The short X.Y version. version = '5.0' # The full version, including alpha/beta/rc tags. -release = '5.0.6' +release = '5.0.7' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index d3095df5..2ee158f7 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -3,6 +3,7 @@ ChangeLog Vesion 5.0.7 (2019-mm-dd) ------------------------- +- This version officially supports the new PostgreSQL 11. - Fixed a bug in parsing array subscript ranges (reported by Justin Pryzby). Vesion 5.0.6 (2018-07-29) diff --git a/docs/contents/general.rst b/docs/contents/general.rst index c97ca7c7..51644b93 100644 --- a/docs/contents/general.rst +++ b/docs/contents/general.rst @@ -15,7 +15,7 @@ provides some higher-level and PostgreSQL specific convenience methods. .. seealso:: **DB-API 2.0** (Python Database API Specification v2.0) - is a specification for connecting to databases (not only PostGreSQL) + is a specification for connecting to databases (not only PostgreSQL) from Python that has been developed by the Python DB-SIG in 1999. The authoritative programming information for the DB-API is :pep:`0249`. diff --git a/docs/contents/install.rst b/docs/contents/install.rst index ac4f360d..4f9dd403 100644 --- a/docs/contents/install.rst +++ b/docs/contents/install.rst @@ -11,7 +11,7 @@ are on Windows, make sure that the directory with libpq.dll is in your ``PATH`` environment variable. The current version of PyGreSQL has been tested with Python versions -2.6, 2.7 and 3.3 to 3.7, and PostGreSQL versions 9.0 to 9.6 and 10. +2.6, 2.7 and 3.3 to 3.7, and PostgreSQL versions 9.0 to 9.6 and 10 or 11. PyGreSQL will be installed as three modules, a dynamic module called _pg.pyd, and two pure Python wrapper modules called pg.py and pgdb.py. diff --git a/docs/contents/pg/adaptation.rst b/docs/contents/pg/adaptation.rst index c9534434..e7134f63 100644 --- a/docs/contents/pg/adaptation.rst +++ b/docs/contents/pg/adaptation.rst @@ -363,7 +363,7 @@ With PostgreSQL we can easily calculate that these two circles overlap:: True However, calculating the intersection points between the two circles using the -``#`` operator does not work (at least not as of PostgreSQL version 10). +``#`` operator does not work (at least not as of PostgreSQL version 11). So let's resort to SymPy to find out. To ease importing circles from PostgreSQL to SymPy, we create and register the following typecast function:: diff --git a/docs/contents/pg/connection.rst b/docs/contents/pg/connection.rst index 4c40e700..5729050f 100644 --- a/docs/contents/pg/connection.rst +++ b/docs/contents/pg/connection.rst @@ -76,7 +76,7 @@ reset -- reset the connection .. method:: Connection.reset() Reset the :mod:`pg` connection - + :rtype: None :raises TypeError: too many (any) arguments :raises TypeError: invalid connection @@ -101,7 +101,7 @@ close -- close the database connection .. method:: Connection.close() Close the :mod:`pg` connection - + :rtype: None :raises TypeError: too many (any) arguments @@ -352,7 +352,7 @@ locreate -- create a large object in the database [LO] Create a large object in the database :param int mode: large object create mode - :returns: object handling the PostGreSQL large object + :returns: object handling the PostgreSQL large object :rtype: :class:`LargeObject` :raises TypeError: invalid connection, bad parameter type, or too many parameters :raises pg.OperationalError: creation error @@ -370,7 +370,7 @@ getlo -- build a large object from given oid [LO] Create a large object in the database :param int oid: OID of the existing large object - :returns: object handling the PostGreSQL large object + :returns: object handling the PostgreSQL large object :rtype: :class:`LargeObject` :raises TypeError: invalid connection, bad parameter type, or too many parameters :raises ValueError: bad OID value (0 is invalid_oid) @@ -386,7 +386,7 @@ loimport -- import a file to a large object [LO] Import a file to a large object :param str name: the name of the file to be imported - :returns: object handling the PostGreSQL large object + :returns: object handling the PostgreSQL large object :rtype: :class:`LargeObject` :raises TypeError: invalid connection, bad argument type, or too many arguments :raises pg.OperationalError: error during file import diff --git a/docs/contents/pg/module.rst b/docs/contents/pg/module.rst index 62d426df..6e5a9d0d 100644 --- a/docs/contents/pg/module.rst +++ b/docs/contents/pg/module.rst @@ -370,7 +370,7 @@ get/set_decimal_point -- decimal mark used for monetary values This function returns the decimal mark used by PyGreSQL to interpret PostgreSQL monetary values when converting them to decimal numbers. The default setting is ``'.'`` as a decimal point. This setting is not -adapted automatically to the locale used by PostGreSQL, but you can use +adapted automatically to the locale used by PostgreSQL, but you can use :func:`set_decimal()` to set a different decimal mark manually. A return value of ``None`` means monetary values are not interpreted as decimal numbers, but returned as strings including the formatting and currency. @@ -386,7 +386,7 @@ numbers, but returned as strings including the formatting and currency. This function can be used to specify the decimal mark used by PyGreSQL to interpret PostgreSQL monetary values. The default value is '.' as a decimal point. This value is not adapted automatically to the locale -used by PostGreSQL, so if you are dealing with a database set to a +used by PostgreSQL, so if you are dealing with a database set to a locale that uses a ``','`` instead of ``'.'`` as the decimal point, then you need to call ``set_decimal(',')`` to have PyGreSQL interpret monetary values correctly. If you don't want money values to be converted diff --git a/docs/contents/pgdb/introduction.rst b/docs/contents/pgdb/introduction.rst index 7c8bd42d..5eb4f0a8 100644 --- a/docs/contents/pgdb/introduction.rst +++ b/docs/contents/pgdb/introduction.rst @@ -8,7 +8,7 @@ provided by the :mod:`pgdb` module. The following part of the documentation covers only the newer :mod:`pgdb` API. **DB-API 2.0** (Python Database API Specification v2.0) -is a specification for connecting to databases (not only PostGreSQL) +is a specification for connecting to databases (not only PostgreSQL) from Python that has been developed by the Python DB-SIG in 1999. The authoritative programming information for the DB-API is :pep:`0249`. diff --git a/docs/download/download.rst b/docs/download/download.rst index b8e289a2..13f23cf7 100644 --- a/docs/download/download.rst +++ b/docs/download/download.rst @@ -17,12 +17,12 @@ A **FreeBSD package** is available in their ports collection An **openSUSE package** is available through their build service at * https://software.opensuse.org/package/PyGreSQL?search_term=pygresql A **Win32 installer** for various Python versions is available at - * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py2.6.exe - * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py2.7.exe - * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.4.exe - * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.5.exe - * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.6.exe - * http://pygresql.org/files/PyGreSQL-5.0.6.win-amd64-py3.7.exe + * http://pygresql.org/files/PyGreSQL-5.0.7.win-amd64-py2.6.exe + * http://pygresql.org/files/PyGreSQL-5.0.7.win-amd64-py2.7.exe + * http://pygresql.org/files/PyGreSQL-5.0.7.win-amd64-py3.4.exe + * http://pygresql.org/files/PyGreSQL-5.0.7.win-amd64-py3.5.exe + * http://pygresql.org/files/PyGreSQL-5.0.7.win-amd64-py3.6.exe + * http://pygresql.org/files/PyGreSQL-5.0.7.win-amd64-py3.7.exe Older PyGreSQL versions ----------------------- diff --git a/mktar b/mktar index ae6f5e59..db4b050b 100755 --- a/mktar +++ b/mktar @@ -1,6 +1,6 @@ #! /bin/sh -VERSION=5.0.6 +VERSION=5.0.7 DISTDIR=/u/WEB/pyg/files # some safety tests diff --git a/pg.py b/pg.py index 23c4abae..b80d82a3 100644 --- a/pg.py +++ b/pg.py @@ -1472,7 +1472,7 @@ def pgnotify(*args, **kw): return NotificationHandler(*args, **kw) -# The actual PostGreSQL database connection interface: +# The actual PostgreSQL database connection interface: class DB: """Wrapper class for the _pg connection type.""" diff --git a/setup.py b/setup.py index 292a376f..1130e99d 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #! /usr/bin/python # $Id$ -"""Setup script for PyGreSQL version 5.0.6 +"""Setup script for PyGreSQL version 5.0.7 PyGreSQL is an open-source Python module that interfaces to a PostgreSQL database. It embeds the PostgreSQL query library to allow @@ -33,7 +33,7 @@ """ -version = '5.0.6' +version = '5.0.7' import sys diff --git a/tests/test_classic_connection.py b/tests/test_classic_connection.py index 121f1dee..4ea92940 100755 --- a/tests/test_classic_connection.py +++ b/tests/test_classic_connection.py @@ -163,7 +163,7 @@ def testAttributeProtocolVersion(self): def testAttributeServerVersion(self): server_version = self.connection.server_version self.assertIsInstance(server_version, int) - self.assertTrue(90000 <= server_version < 110000) + self.assertTrue(90000 <= server_version < 120000) def testAttributeStatus(self): status_ok = 1 diff --git a/tests/test_classic_dbwrapper.py b/tests/test_classic_dbwrapper.py index 05dd4ef2..4181da0d 100755 --- a/tests/test_classic_dbwrapper.py +++ b/tests/test_classic_dbwrapper.py @@ -274,7 +274,7 @@ def testAttributeProtocolVersion(self): def testAttributeServerVersion(self): server_version = self.db.server_version self.assertIsInstance(server_version, int) - self.assertTrue(90000 <= server_version < 110000) + self.assertTrue(90000 <= server_version < 120000) self.assertEqual(server_version, self.db.db.server_version) def testAttributeStatus(self): From 27759689e93f6c222ea74e2893e8a9e829ff46c2 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 4 Jan 2019 22:32:04 +0000 Subject: [PATCH 17/26] Some improvements to the docs by Justin Pryzby --- docs/contents/pg/adaptation.rst | 2 +- docs/contents/pg/connection.rst | 2 +- docs/contents/pg/db_wrapper.rst | 4 ++-- docs/contents/pg/query.rst | 2 +- docs/contents/postgres/advanced.rst | 2 +- docs/contents/postgres/func.rst | 2 +- docs/contents/postgres/syscat.rst | 9 ++++++--- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/contents/pg/adaptation.rst b/docs/contents/pg/adaptation.rst index e7134f63..02f378ca 100644 --- a/docs/contents/pg/adaptation.rst +++ b/docs/contents/pg/adaptation.rst @@ -64,7 +64,7 @@ adaptation of parameters, since all of this is happening automatically behind the scenes. You only need to consider this issue when creating SQL commands manually and sending them to the database using the :meth:`DB.query` method. -Imagine you have created a user login form that stores the login name as +Imagine you have created a user login form that stores the login name as *login* and the password as *passwd* and you now want to get the user data for that user. You may be tempted to execute a query like this:: diff --git a/docs/contents/pg/connection.rst b/docs/contents/pg/connection.rst index 5729050f..ff8db4fb 100644 --- a/docs/contents/pg/connection.rst +++ b/docs/contents/pg/connection.rst @@ -241,7 +241,7 @@ values may contain string, integer, long or double (real) values. .. warning:: This method doesn't type check the fields according to the table definition; - it just look whether or not it knows how to handle such types. + it just looks whether or not it knows how to handle such types. get/set_notice_receiver -- custom notice receiver ------------------------------------------------- diff --git a/docs/contents/pg/db_wrapper.rst b/docs/contents/pg/db_wrapper.rst index efb82c62..52d06480 100644 --- a/docs/contents/pg/db_wrapper.rst +++ b/docs/contents/pg/db_wrapper.rst @@ -314,7 +314,7 @@ If *row* is a dictionary, then the value for the key is taken from it. Otherwise, the row must be a single value or a tuple of values corresponding to the passed *keyname* or primary key. The fetched row from the table will be returned as a new dictionary or used to replace -the existing values when row was passed as aa dictionary. +the existing values when row was passed as a dictionary. The OID is also put into the dictionary if the table has one, but in order to allow the caller to work with multiple tables, it is @@ -775,7 +775,7 @@ JSON data is automatically decoded by PyGreSQL. If you don't want the data to be decoded, then you can cast ``json`` or ``jsonb`` columns to ``text`` in PostgreSQL or you can set the decoding function to *None* or a different function using :func:`pg.set_jsondecode`. By default this is the same as -the :func:`json.dumps` function from the standard library. +the :func:`json.loads` function from the standard library. .. versionadded:: 5.0 diff --git a/docs/contents/pg/query.rst b/docs/contents/pg/query.rst index 55e8b543..2be12073 100644 --- a/docs/contents/pg/query.rst +++ b/docs/contents/pg/query.rst @@ -42,7 +42,7 @@ dictresult -- get query values as list of dictionaries :raises MemoryError: internal memory error This method returns the list of the values returned by the query -with each tuple returned as a dictionary with the field names +with each row returned as a dictionary with the field names used as the dictionary index. Note that since PyGreSQL 5.0 this will return the values of array type diff --git a/docs/contents/postgres/advanced.rst b/docs/contents/postgres/advanced.rst index 65d02ecd..38c8a473 100644 --- a/docs/contents/postgres/advanced.rst +++ b/docs/contents/postgres/advanced.rst @@ -11,7 +11,7 @@ database, as explained in the :doc:`basic`:: >>> from pg import DB >>> db = DB() - >>> query = query + >>> query = db.query Inheritance ----------- diff --git a/docs/contents/postgres/func.rst b/docs/contents/postgres/func.rst index c2d5dd63..5dba156a 100644 --- a/docs/contents/postgres/func.rst +++ b/docs/contents/postgres/func.rst @@ -22,7 +22,7 @@ Let's create a simple SQL function that takes no arguments and returns 1:: >>> query("""CREATE FUNCTION one() RETURNS int4 ... AS 'SELECT 1 as ONE' LANGUAGE SQL""") -Functions can be used in any expressions (eg. in the target"list or +Functions can be used in any expressions (eg. in the target list or qualifications):: >>> print(db.query("SELECT one() AS answer")) diff --git a/docs/contents/postgres/syscat.rst b/docs/contents/postgres/syscat.rst index 1fcca4fc..0c34c834 100644 --- a/docs/contents/postgres/syscat.rst +++ b/docs/contents/postgres/syscat.rst @@ -19,7 +19,8 @@ database, as explained in the :doc:`basic`:: >>> from pg import DB >>> db = DB() - >>> query = query + >>> query = db.query + Lists indices ------------- @@ -49,6 +50,7 @@ in user-defined classes:: AND NOT a.attisdropped ORDER BY relname, attname""")) + List user defined base types ---------------------------- @@ -62,8 +64,8 @@ This query lists all user defined base types:: ORDER BY rolname, typname""")) -List operators ---------------- +List operators +-------------- This query lists all right-unary operators:: @@ -121,6 +123,7 @@ they can be applied:: and p.proargtypes[0] = t.oid ORDER BY proname, typname""")) + List operator families ---------------------- From 2afb524b37619c42fb5be4eb8d3953ba4c8865cb Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Sat, 5 Jan 2019 11:59:18 +0000 Subject: [PATCH 18/26] Fix doc error: get/set_cast_hook are connection methods --- docs/contents/pg/connection.rst | 33 +++++++++++++++++++++++++++++++++ docs/contents/pg/module.rst | 23 ----------------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/docs/contents/pg/connection.rst b/docs/contents/pg/connection.rst index ff8db4fb..654c9333 100644 --- a/docs/contents/pg/connection.rst +++ b/docs/contents/pg/connection.rst @@ -243,6 +243,39 @@ values may contain string, integer, long or double (real) values. This method doesn't type check the fields according to the table definition; it just looks whether or not it knows how to handle such types. +get/set_cast_hook -- fallback typecast function +----------------------------------------------- + +.. method:: Connection.get_cast_hook() + + Get the function that handles all external typecasting + + :returns: the current external typecast function + :rtype: callable, None + :raises TypeError: too many (any) arguments + +This returns the callback function used by PyGreSQL to provide plug-in +Python typecast functions for the connection. + +.. versionadded:: 5.0 + +.. method:: Connection.set_cast_hook(func) + + Set a function that will handle all external typecasting + + :param func: the function to be used as a callback + :rtype: None + :raises TypeError: the specified notice receiver is not callable + +This methods allows setting a custom fallback function for providing +Python typecast functions for the connection to supplement the C +extension module. If you set this function to *None*, then only the typecast +functions implemented in the C extension module are enabled. You normally +would not want to change this. Instead, you can use :func:`get_typecast` and +:func:`set_typecast` to add or change the plug-in Python typecast functions. + +.. versionadded:: 5.0 + get/set_notice_receiver -- custom notice receiver ------------------------------------------------- diff --git a/docs/contents/pg/module.rst b/docs/contents/pg/module.rst index 6e5a9d0d..0a064f42 100644 --- a/docs/contents/pg/module.rst +++ b/docs/contents/pg/module.rst @@ -524,29 +524,6 @@ the automatic deserialization of JSON strings will be deactivated. .. versionchanged:: 5.0 JSON data had been always returned as text strings in earlier versions. -get/set_cast_hook -- fallback typecast function ------------------------------------------------ - -.. function:: get_cast_hook() - - Get the function that handles all external typecasting - -This returns the callback function used by PyGreSQL to provide plug-in -Python typecast functions. - -.. function:: set_cast_hook(func) - - Set a function that will handle all external typecasting - - :param func: the function to be used as a callback - -If you set this function to *None*, then only the typecast functions -implemented in the C extension module are enabled. You normally would -not want to change this. Instead, you can use :func:`get_typecast` and -:func:`set_typecast` to add or change the plug-in Python typecast functions. - -.. versionadded:: 5.0 - get/set_datestyle -- assume a fixed date style ---------------------------------------------- From 8fc06ed4886bb03d8f2436cf2e9c72fe1f30ad65 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Sat, 5 Jan 2019 13:51:23 +0000 Subject: [PATCH 19/26] Graceful exit of DB destructor on closed connection Also, in the 5.1 branch, the DB wrapper can now be closed (without closing the underlying connection) and reopened (reusing the same connection). This fixed GitHub issue #11 --- docs/contents/changelog.rst | 2 ++ pg.py | 16 +++++++++++++--- tests/test_classic_dbwrapper.py | 32 ++++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index 2ee158f7..21abe3dc 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -5,6 +5,8 @@ Vesion 5.0.7 (2019-mm-dd) ------------------------- - This version officially supports the new PostgreSQL 11. - Fixed a bug in parsing array subscript ranges (reported by Justin Pryzby). +- Fixed an issue when deleting a DB wrapper object with the underlying + connection already closed (bug report by Jacob Champion). Vesion 5.0.6 (2018-07-29) ------------------------- diff --git a/pg.py b/pg.py index b80d82a3..f7ff6c8e 100644 --- a/pg.py +++ b/pg.py @@ -1572,9 +1572,15 @@ def __del__(self): except AttributeError: db = None if db: - db.set_cast_hook(None) + try: + db.set_cast_hook(None) + except TypeError: + pass # probably already closed if self._closeable: - db.close() + try: + db.close() + except InternalError: + pass # probably already closed # Auxiliary methods @@ -1631,7 +1637,10 @@ def close(self): # Wraps shared library function so we can track state. if self._closeable: if self.db: - self.db.set_cast_hook(None) + try: + self.db.set_cast_hook(None) + except TypeError: + pass # probably already closed self.db.close() self.db = None else: @@ -1662,6 +1671,7 @@ def reopen(self): if self.db: self.db.set_cast_hook(None) self.db.close() + db.set_cast_hook(self.dbtypes.typecast) self.db = db def begin(self, mode=None): diff --git a/tests/test_classic_dbwrapper.py b/tests/test_classic_dbwrapper.py index 4181da0d..4ec906e3 100755 --- a/tests/test_classic_dbwrapper.py +++ b/tests/test_classic_dbwrapper.py @@ -374,26 +374,42 @@ def testMethodReopen(self): def testExistingConnection(self): db = pg.DB(self.db.db) + self.assertIsNotNone(db.db) self.assertEqual(self.db.db, db.db) - self.assertTrue(db.db) db.close() - self.assertTrue(db.db) + self.assertIsNotNone(db.db) + self.assertIsNotNone(self.db.db) db.reopen() - self.assertTrue(db.db) + self.assertIsNotNone(db.db) + self.assertEqual(self.db.db, db.db) db.close() - self.assertTrue(db.db) + self.assertIsNotNone(db.db) db = pg.DB(self.db) self.assertEqual(self.db.db, db.db) db = pg.DB(db=self.db.db) self.assertEqual(self.db.db, db.db) - class DB2: - pass + def testExistingDbApi2Connection(self): + + class DBApi2Con: + + def __init__(self, cnx): + self._cnx = cnx + + def close(self): + self._cnx.close() - db2 = DB2() - db2._cnx = self.db.db + db2 = DBApi2Con(self.db.db) db = pg.DB(db2) self.assertEqual(self.db.db, db.db) + db.close() + self.assertIsNotNone(db.db) + db.reopen() + self.assertIsNotNone(db.db) + self.assertEqual(self.db.db, db.db) + db.close() + self.assertIsNotNone(db.db) + db2.close() class TestDBClass(unittest.TestCase): From ab920508b5a17d05dc92cbb367a36b8f383f2e8d Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Sat, 5 Jan 2019 15:42:17 +0000 Subject: [PATCH 20/26] Avoid warning in Python 3.7 (and error later in 3.8) --- pgdb.py | 6 +++++- tests/test_dbapi20_copy.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pgdb.py b/pgdb.py index 8cd2662a..38ebeafb 100644 --- a/pgdb.py +++ b/pgdb.py @@ -74,7 +74,11 @@ from decimal import Decimal from uuid import UUID as Uuid from math import isnan, isinf -from collections import namedtuple, Iterable +try: + from collections.abc import Iterable +except ImportError: # Python < 3.3 + from collections import Iterable +from collections import namedtuple from keyword import iskeyword from functools import partial from re import compile as regex diff --git a/tests/test_dbapi20_copy.py b/tests/test_dbapi20_copy.py index f7b572df..9d5d04ce 100644 --- a/tests/test_dbapi20_copy.py +++ b/tests/test_dbapi20_copy.py @@ -15,7 +15,10 @@ except ImportError: import unittest -from collections import Iterable +try: + from collections.abc import Iterable +except ImportError: # Python < 3.3 + from collections import Iterable import pgdb # the module under test From 11a4c13674605d0102643d5cb05cd1df0bcb6741 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 19 Apr 2019 18:27:41 +0000 Subject: [PATCH 21/26] Minor code simplification in format_query() --- pg.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pg.py b/pg.py index f7ff6c8e..222ce2db 100644 --- a/pg.py +++ b/pg.py @@ -691,17 +691,14 @@ def format_query(self, command, values=None, types=None, inline=False): literals = [adapt(value) for value in values] else: add = params.add - literals = [] - append = literals.append if types: if (not isinstance(types, (list, tuple)) or len(types) != len(values)): raise TypeError('The values and types do not match') - for value, typ in zip(values, types): - append(add(value, typ)) + literals = [add(value, typ) + for value, typ in zip(values, types)] else: - for value in values: - append(add(value)) + literals = [add(value) for value in values] command %= tuple(literals) elif isinstance(values, dict): # we want to allow extra keys in the dictionary, @@ -722,15 +719,14 @@ def format_query(self, command, values=None, types=None, inline=False): for key, value in values.items()) else: add = params.add - literals = {} if types: if not isinstance(types, dict): raise TypeError('The values and types do not match') - for key in sorted(values): - literals[key] = add(values[key], types.get(key)) + literals = dict((key, add(values[key], types.get(key))) + for key in sorted(values)) else: - for key in sorted(values): - literals[key] = add(values[key]) + literals = dict((key, add(values[key])) + for key in sorted(values)) command %= literals else: raise TypeError('The values must be passed as tuple, list or dict') From 33058a54a6076345548d357f343f8122b1fec932 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Sun, 21 Apr 2019 19:28:33 +0000 Subject: [PATCH 22/26] Add version note for get_as_list/dict --- docs/contents/pg/db_wrapper.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/contents/pg/db_wrapper.rst b/docs/contents/pg/db_wrapper.rst index 52d06480..cd0fea92 100644 --- a/docs/contents/pg/db_wrapper.rst +++ b/docs/contents/pg/db_wrapper.rst @@ -621,6 +621,8 @@ If you set the *scalar* option to *True*, then instead of the named tuples you will get the first items of these tuples. This is useful if the result has only one column anyway. +.. versionadded:: 5.0 + .. method:: DB.get_as_dict(table, [keyname], [what], [where], [order], [limit], [offset], [scalar]) Get a table as a dictionary @@ -657,6 +659,8 @@ using the order specified with the *order* parameter or the key column(s) if not specified. You can set *order* to *False* if you don't care about the ordering. In this case the returned dictionary will be an ordinary one. +.. versionadded:: 5.0 + escape_literal/identifier/string/bytea -- escape for SQL -------------------------------------------------------- From bf9a9ce45118225c5685c1c25dc04f42703835f6 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Wed, 24 Apr 2019 20:16:19 +0000 Subject: [PATCH 23/26] Document how to send more parameters with connect --- docs/contents/pg/module.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/contents/pg/module.rst b/docs/contents/pg/module.rst index 0a064f42..15205ee8 100644 --- a/docs/contents/pg/module.rst +++ b/docs/contents/pg/module.rst @@ -46,15 +46,22 @@ connect -- Open a PostgreSQL connection This function opens a connection to a specified database on a given PostgreSQL server. You can use keywords here, as described in the Python tutorial. The names of the keywords are the name of the -parameters given in the syntax line. For a precise description +parameters given in the syntax line. The ``opt`` parameter can be used +to pass command-line options to the server. For a precise description of the parameters, please refer to the PostgreSQL user manual. +If you want to add additional parameters not specified here, you must +pass a connection string or a connection URI instead of the ``dbname`` +(as in ``con3`` and ``con4`` in the following example). + Example:: import pg - con1 = pg.connect('testdb', 'myhost', 5432, None, None, 'bob', None) - con2 = pg.connect(dbname='testdb', host='localhost', user='bob') + con1 = pg.connect('testdb', 'myhost', 5432, None, 'bob', None) + con2 = pg.connect(dbname='testdb', host='myhost', user='bob') + con3 = pg.connect('host=myhost user=bob dbname=testdb connect_timeout=10') + con4 = pg.connect('postgresql://bob@myhost/testdb?connect_timeout=10') get/set_defhost -- default server host [DV] ------------------------------------------- From 49251309fe9af5fba57b1be577aee8f20c781269 Mon Sep 17 00:00:00 2001 From: "D'Arcy J.M. Cain" Date: Wed, 15 May 2019 14:07:02 +0000 Subject: [PATCH 24/26] Copy changes from the 5.0.7 tag to the 5.0.x branch. --- docs/Makefile | 2 +- docs/announce.rst | 5 +---- docs/contents/changelog.rst | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index bbe5bf09..0a1113c9 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = -SPHINXBUILD = sphinx-build3.6 +SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build diff --git a/docs/announce.rst b/docs/announce.rst index ae71a1cb..8a0ca715 100644 --- a/docs/announce.rst +++ b/docs/announce.rst @@ -13,12 +13,9 @@ It is available at: http://pygresql.org/files/PyGreSQL-5.0.7.tar.gz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection. -Please refer to `changelog.txt `_ +Please refer to `changelog.txt `_ for things that have changed in this version. -Please refer to `readme.txt `_ -for general information. - This version has been built and unit tested on: - NetBSD - FreeBSD diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index 21abe3dc..ed48ab57 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -1,7 +1,7 @@ ChangeLog ========= -Vesion 5.0.7 (2019-mm-dd) +Vesion 5.0.7 (2019-05-15) ------------------------- - This version officially supports the new PostgreSQL 11. - Fixed a bug in parsing array subscript ranges (reported by Justin Pryzby). From d35d8426cb8005e3ba9de15a5af3d0b5a0718e28 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 17 May 2019 20:00:56 +0000 Subject: [PATCH 25/26] Add files for building docs to manifest template Note that index.rst will be copied from start.txt or toc.txt depending on the theme and therefore should not be included. --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index b2681522..083f4246 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -18,6 +18,8 @@ include docs/Makefile include docs/make.bat include docs/*.py include docs/*.rst +include docs/*.txt +exclude docs/index.rst recursive-include docs/community *.rst recursive-include docs/contents *.rst recursive-include docs/download *.rst From 02c80c0f3c463555e8c621dff200274a5bc50c27 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 17 May 2019 20:09:02 +0000 Subject: [PATCH 26/26] Shift release date --- docs/contents/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contents/changelog.rst b/docs/contents/changelog.rst index ed48ab57..75f276de 100644 --- a/docs/contents/changelog.rst +++ b/docs/contents/changelog.rst @@ -1,7 +1,7 @@ ChangeLog ========= -Vesion 5.0.7 (2019-05-15) +Vesion 5.0.7 (2019-05-17) ------------------------- - This version officially supports the new PostgreSQL 11. - Fixed a bug in parsing array subscript ranges (reported by Justin Pryzby).