PyGreSQL 5.2.3__tar.gz → 5.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/LICENSE.txt +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/PKG-INFO +4 -3
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/PyGreSQL.egg-info/PKG-INFO +4 -3
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/README.rst +2 -2
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/about.txt +7 -7
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/announce.rst +4 -4
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/conf.py +2 -2
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/changelog.rst +31 -8
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/install.rst +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/connection.rst +2 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/db_wrapper.rst +14 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/copyright.rst +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/requirements.txt +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pg.py +52 -11
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pgconn.c +139 -63
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pgdb.py +2 -2
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pginternal.c +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pglarge.c +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pgmodule.c +2 -2
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pgnotice.c +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pgquery.c +10 -5
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pgsource.c +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/setup.py +8 -7
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_classic_connection.py +68 -12
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_classic_dbwrapper.py +161 -5
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_classic_functions.py +1 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_dbapi20.py +13 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_tutorial.py +2 -1
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tox.ini +8 -7
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/MANIFEST.in +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/PyGreSQL.egg-info/SOURCES.txt +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/PyGreSQL.egg-info/dependency_links.txt +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/PyGreSQL.egg-info/not-zip-safe +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/PyGreSQL.egg-info/top_level.txt +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/Makefile +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/_static/favicon.ico +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/_static/pygresql.css_t +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/_static/pygresql.png +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/_templates/layout.html +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/about.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/community/homes.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/community/index.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/community/issues.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/community/mailinglist.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/community/source.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/community/support.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/examples.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/general.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/index.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/adaptation.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/db_types.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/index.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/introduction.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/large_objects.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/module.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/notification.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pg/query.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/adaptation.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/connection.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/cursor.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/index.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/introduction.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/module.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/typecache.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/pgdb/types.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/postgres/advanced.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/postgres/basic.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/postgres/func.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/postgres/index.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/postgres/syscat.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/contents/tutorial.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/download/download.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/download/files.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/download/index.rst +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/make.bat +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/start.txt +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/docs/toc.txt +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/pgtypes.h +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/py3c.h +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/setup.cfg +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/__init__.py +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/config.py +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/dbapi20.py +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_classic.py +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_classic_largeobj.py +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_classic_notification.py +0 -0
- {PyGreSQL-5.2.3 → PyGreSQL-5.2.5}/tests/test_dbapi20_copy.py +0 -0
|
@@ -6,7 +6,7 @@ Copyright (c) 1995, Pascal Andre
|
|
|
6
6
|
|
|
7
7
|
Further modifications copyright (c) 1997-2008 by D'Arcy J.M. Cain
|
|
8
8
|
|
|
9
|
-
Further modifications copyright (c) 2009-
|
|
9
|
+
Further modifications copyright (c) 2009-2023 by the PyGreSQL Development Team
|
|
10
10
|
|
|
11
11
|
PyGreSQL is released under the PostgreSQL License, a liberal Open Source
|
|
12
12
|
license, similar to the BSD or MIT licenses:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyGreSQL
|
|
3
|
-
Version: 5.2.
|
|
3
|
+
Version: 5.2.5
|
|
4
4
|
Summary: Python PostgreSQL Interfaces
|
|
5
5
|
Home-page: http://www.pygresql.org
|
|
6
6
|
Author: D'Arcy J. M. Cain
|
|
@@ -28,6 +28,7 @@ Classifier: Programming Language :: Python :: 3.7
|
|
|
28
28
|
Classifier: Programming Language :: Python :: 3.8
|
|
29
29
|
Classifier: Programming Language :: Python :: 3.9
|
|
30
30
|
Classifier: Programming Language :: Python :: 3.10
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
31
32
|
Classifier: Programming Language :: SQL
|
|
32
33
|
Classifier: Topic :: Database
|
|
33
34
|
Classifier: Topic :: Database :: Front-Ends
|
|
@@ -36,6 +37,6 @@ Description-Content-Type: text/plain
|
|
|
36
37
|
License-File: LICENSE.txt
|
|
37
38
|
|
|
38
39
|
PyGreSQL is an open-source Python module that interfaces to a
|
|
39
|
-
PostgreSQL database. It
|
|
40
|
-
easy use of the powerful PostgreSQL features from
|
|
40
|
+
PostgreSQL database. It wraps the lower level C API library libpq
|
|
41
|
+
to allow easy use of the powerful PostgreSQL features from Python.
|
|
41
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyGreSQL
|
|
3
|
-
Version: 5.2.
|
|
3
|
+
Version: 5.2.5
|
|
4
4
|
Summary: Python PostgreSQL Interfaces
|
|
5
5
|
Home-page: http://www.pygresql.org
|
|
6
6
|
Author: D'Arcy J. M. Cain
|
|
@@ -28,6 +28,7 @@ Classifier: Programming Language :: Python :: 3.7
|
|
|
28
28
|
Classifier: Programming Language :: Python :: 3.8
|
|
29
29
|
Classifier: Programming Language :: Python :: 3.9
|
|
30
30
|
Classifier: Programming Language :: Python :: 3.10
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
31
32
|
Classifier: Programming Language :: SQL
|
|
32
33
|
Classifier: Topic :: Database
|
|
33
34
|
Classifier: Topic :: Database :: Front-Ends
|
|
@@ -36,6 +37,6 @@ Description-Content-Type: text/plain
|
|
|
36
37
|
License-File: LICENSE.txt
|
|
37
38
|
|
|
38
39
|
PyGreSQL is an open-source Python module that interfaces to a
|
|
39
|
-
PostgreSQL database. It
|
|
40
|
-
easy use of the powerful PostgreSQL features from
|
|
40
|
+
PostgreSQL database. It wraps the lower level C API library libpq
|
|
41
|
+
to allow easy use of the powerful PostgreSQL features from Python.
|
|
41
42
|
|
|
@@ -2,8 +2,8 @@ PyGreSQL - Python interface for PostgreSQL
|
|
|
2
2
|
==========================================
|
|
3
3
|
|
|
4
4
|
PyGreSQL is a Python module that interfaces to a PostgreSQL database.
|
|
5
|
-
It
|
|
6
|
-
PostgreSQL features from
|
|
5
|
+
It wraps the lower level C API library libpq to allow easy use of the
|
|
6
|
+
powerful PostgreSQL features from Python.
|
|
7
7
|
|
|
8
8
|
PyGreSQL should run on most platforms where PostgreSQL and Python is running.
|
|
9
9
|
It is based on the PyGres95 code written by Pascal Andre.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
**PyGreSQL** is an *open-source* `Python <http://www.python.org>`_ module
|
|
2
2
|
that interfaces to a `PostgreSQL <http://www.postgresql.org>`_ database.
|
|
3
|
-
It
|
|
4
|
-
PostgreSQL features from
|
|
3
|
+
It wraps the lower level C API library libpq to allow easy use of the
|
|
4
|
+
powerful PostgreSQL features from Python.
|
|
5
5
|
|
|
6
6
|
| This software is copyright © 1995, Pascal Andre.
|
|
7
7
|
| Further modifications are copyright © 1997-2008 by D'Arcy J.M. Cain.
|
|
8
|
-
| Further modifications are copyright © 2009-
|
|
8
|
+
| Further modifications are copyright © 2009-2023 by the PyGreSQL team.
|
|
9
9
|
| For licensing details, see the full :doc:`copyright`.
|
|
10
10
|
|
|
11
11
|
**PostgreSQL** is a highly scalable, SQL compliant, open source
|
|
@@ -27,8 +27,8 @@ The Python implementation is copyrighted but freely usable and distributable,
|
|
|
27
27
|
even for commercial use.
|
|
28
28
|
|
|
29
29
|
**PyGreSQL** is a Python module that interfaces to a PostgreSQL database.
|
|
30
|
-
It
|
|
31
|
-
PostgreSQL features from
|
|
30
|
+
It wraps the lower level C API library libpq to allow easy use of the
|
|
31
|
+
powerful PostgreSQL features from Python.
|
|
32
32
|
|
|
33
33
|
PyGreSQL is developed and tested on a NetBSD system, but it also runs on
|
|
34
34
|
most other platforms where PostgreSQL and Python is running. It is based
|
|
@@ -36,7 +36,7 @@ on the PyGres95 code written by Pascal Andre (andre@chimay.via.ecp.fr).
|
|
|
36
36
|
D'Arcy (darcy@druid.net) renamed it to PyGreSQL starting with
|
|
37
37
|
version 2.0 and serves as the "BDFL" of PyGreSQL.
|
|
38
38
|
|
|
39
|
-
The current version PyGreSQL 5.2.
|
|
40
|
-
Python 2.7 or 3.5 to 3.
|
|
39
|
+
The current version PyGreSQL 5.2.5 needs PostgreSQL 9.0 to 9.6 or 10 to 15, and
|
|
40
|
+
Python 2.7 or 3.5 to 3.11. If you need to support older PostgreSQL versions or
|
|
41
41
|
older Python 2.x versions, you can resort to the PyGreSQL 4.x versions that
|
|
42
42
|
still support them.
|
|
@@ -3,10 +3,10 @@ PyGreSQL Announcements
|
|
|
3
3
|
======================
|
|
4
4
|
|
|
5
5
|
---------------------------------
|
|
6
|
-
Release of PyGreSQL version 5.2.
|
|
6
|
+
Release of PyGreSQL version 5.2.5
|
|
7
7
|
---------------------------------
|
|
8
8
|
|
|
9
|
-
Release 5.2.
|
|
9
|
+
Release 5.2.5 of PyGreSQL.
|
|
10
10
|
|
|
11
11
|
It is available at: https://pypi.org/project/PyGreSQL/.
|
|
12
12
|
|
|
@@ -22,8 +22,8 @@ This version has been built and unit tested on:
|
|
|
22
22
|
- openSUSE
|
|
23
23
|
- Ubuntu
|
|
24
24
|
- Windows 7 and 10 with both MinGW and Visual Studio
|
|
25
|
-
- PostgreSQL 9.0 to 9.6 and 10 to
|
|
26
|
-
- Python 2.7 and 3.5 to 3.
|
|
25
|
+
- PostgreSQL 9.0 to 9.6 and 10 to 15 (32 and 64bit)
|
|
26
|
+
- Python 2.7 and 3.5 to 3.11 (32 and 64bit)
|
|
27
27
|
|
|
28
28
|
| D'Arcy J.M. Cain
|
|
29
29
|
| darcy@PyGreSQL.org
|
|
@@ -61,14 +61,14 @@ master_doc = 'index'
|
|
|
61
61
|
# General information about the project.
|
|
62
62
|
project = 'PyGreSQL'
|
|
63
63
|
author = 'The PyGreSQL team'
|
|
64
|
-
copyright = '
|
|
64
|
+
copyright = '2023, ' + author
|
|
65
65
|
|
|
66
66
|
# The version info for the project you're documenting, acts as replacement for
|
|
67
67
|
# |version| and |release|, also used in various other places throughout the
|
|
68
68
|
# built documents.
|
|
69
69
|
#
|
|
70
70
|
# The full version, including alpha/beta/rc tags.
|
|
71
|
-
version = release = '5.2.
|
|
71
|
+
version = release = '5.2.5'
|
|
72
72
|
|
|
73
73
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
74
74
|
# for a list of supported languages.
|
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
ChangeLog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
Version 5.2.5 (2023-08-28)
|
|
5
|
+
--------------------------
|
|
6
|
+
- This version officially supports the new Python 3.11 and PostgreSQL 15.
|
|
7
|
+
- Two more improvements in the `inserttable()` method of the `pg` module
|
|
8
|
+
(thanks to Justin Pryzby for this contribution):
|
|
9
|
+
|
|
10
|
+
- error handling has been improved (#72)
|
|
11
|
+
- the method now returns the number of inserted rows (#73)
|
|
12
|
+
- Another improvement in the `pg` module (#83):
|
|
13
|
+
- generated columns can be requested with the `get_generated()` method
|
|
14
|
+
- generated columns are ignored by the insert, update and upsert method
|
|
15
|
+
- Avoid internal query and error when casting the `sql_identifier` type (#82)
|
|
16
|
+
- Fix issue with multiple calls of `getresult()` after `send_query()` (#80)
|
|
17
|
+
|
|
18
|
+
Version 5.2.4 (2022-03-26)
|
|
19
|
+
--------------------------
|
|
20
|
+
- Three more fixes in the `inserttable()` method of the `pg` module:
|
|
21
|
+
- `inserttable()` failed to escape carriage return (#68)
|
|
22
|
+
- Allow larger row sizes up to 64 KB (#69)
|
|
23
|
+
- Fix use after free issue in `inserttable()` (#71)
|
|
24
|
+
- Replace obsolete functions for copy used internally (#59).
|
|
25
|
+
Therefore, `getline()` now does not return `\.` at the end any more.
|
|
26
|
+
|
|
4
27
|
Version 5.2.3 (2022-01-30)
|
|
5
28
|
--------------------------
|
|
6
29
|
- This version officially supports the new Python 3.10 and PostgreSQL 14.
|
|
7
30
|
- Some improvements and fixes in the `inserttable()` method of the `pg` module:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
- Sync with `PQendcopy()` when there was an error (#60)
|
|
32
|
+
- Allow specifying a schema in the table name (#61)
|
|
33
|
+
- Improved check for internal result (#62)
|
|
34
|
+
- Catch buffer overflows when building the copy command
|
|
35
|
+
- Data can now be passed as an iterable, not just list or tuple (#66)
|
|
13
36
|
- Some more fixes in the `pg` module:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
37
|
+
- Fix upsert with limited number of columns (#58).
|
|
38
|
+
- Fix argument handling of `is/set_non_blocking()`.
|
|
39
|
+
- Add missing `get/set_typecasts` in list of exports.
|
|
17
40
|
- Fixed a reference counting issue when casting JSON columns (#57).
|
|
18
41
|
|
|
19
42
|
Version 5.2.2 (2020-12-09)
|
|
@@ -14,7 +14,7 @@ On Windows, you also need to make sure that the directory that contains
|
|
|
14
14
|
``libpq.dll`` is part of your ``PATH`` environment variable.
|
|
15
15
|
|
|
16
16
|
The current version of PyGreSQL has been tested with Python versions
|
|
17
|
-
2.7 and 3.5 to 3.
|
|
17
|
+
2.7 and 3.5 to 3.11, and PostgreSQL versions 9.0 to 9.6 and 10 to 15.
|
|
18
18
|
|
|
19
19
|
PyGreSQL will be installed as three modules, a shared library called
|
|
20
20
|
``_pg.so`` (on Linux) or a DLL called ``_pg.pyd`` (on Windows), and two pure
|
|
@@ -494,7 +494,7 @@ inserttable -- insert an iterable into a table
|
|
|
494
494
|
:param str table: the table name
|
|
495
495
|
:param list values: iterable of row values, which must be lists or tuples
|
|
496
496
|
:param list columns: list or tuple of column names
|
|
497
|
-
:rtype:
|
|
497
|
+
:rtype: int
|
|
498
498
|
:raises TypeError: invalid connection, bad argument type, or too many arguments
|
|
499
499
|
:raises MemoryError: insert buffer could not be allocated
|
|
500
500
|
:raises ValueError: unsupported values
|
|
@@ -506,6 +506,7 @@ of the same size, containing the values for each inserted row.
|
|
|
506
506
|
These may contain string, integer, long or double (real) values.
|
|
507
507
|
``columns`` is an optional tuple or list of column names to be passed on
|
|
508
508
|
to the COPY command.
|
|
509
|
+
The number of rows affected is returned.
|
|
509
510
|
|
|
510
511
|
.. warning::
|
|
511
512
|
|
|
@@ -136,6 +136,20 @@ By default, only a limited number of simple types will be returned.
|
|
|
136
136
|
You can get the registered types instead, if enabled by calling the
|
|
137
137
|
:meth:`DB.use_regtypes` method.
|
|
138
138
|
|
|
139
|
+
get_generated -- get the generated columns of a table
|
|
140
|
+
-----------------------------------------------------
|
|
141
|
+
|
|
142
|
+
.. method:: DB.get_generated(table)
|
|
143
|
+
|
|
144
|
+
Get the generated columns of a table
|
|
145
|
+
|
|
146
|
+
:param str table: name of table
|
|
147
|
+
:returns: an frozenset of column names
|
|
148
|
+
|
|
149
|
+
Given the name of a table, digs out the set of generated columns.
|
|
150
|
+
|
|
151
|
+
.. versionadded:: 5.2.5
|
|
152
|
+
|
|
139
153
|
has_table_privilege -- check table privilege
|
|
140
154
|
--------------------------------------------
|
|
141
155
|
|
|
@@ -10,7 +10,7 @@ Copyright (c) 1995, Pascal Andre
|
|
|
10
10
|
Further modifications copyright (c) 1997-2008 by D'Arcy J.M. Cain
|
|
11
11
|
(darcy@PyGreSQL.org)
|
|
12
12
|
|
|
13
|
-
Further modifications copyright (c) 2009-
|
|
13
|
+
Further modifications copyright (c) 2009-2023 by the PyGreSQL team.
|
|
14
14
|
|
|
15
15
|
Permission to use, copy, modify, and distribute this software and its
|
|
16
16
|
documentation for any purpose, without fee, and without a written agreement
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sphinx>=
|
|
1
|
+
sphinx>=4.4,<5
|
|
2
2
|
cloud_sptheme>=1.10,<2
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# This file contains the classic pg module.
|
|
6
6
|
#
|
|
7
|
-
# Copyright (c)
|
|
7
|
+
# Copyright (c) 2023 by the PyGreSQL Development Team
|
|
8
8
|
#
|
|
9
9
|
# The notification handler is based on pgnotify which is
|
|
10
10
|
# Copyright (c) 2001 Ng Pheng Siong. All rights reserved.
|
|
@@ -99,7 +99,7 @@ from uuid import UUID
|
|
|
99
99
|
|
|
100
100
|
try:
|
|
101
101
|
# noinspection PyUnresolvedReferences
|
|
102
|
-
from typing import Dict, List, Union
|
|
102
|
+
from typing import Dict, List, Union # noqa: F401
|
|
103
103
|
has_typing = True
|
|
104
104
|
except ImportError: # Python < 3.5
|
|
105
105
|
has_typing = False
|
|
@@ -1066,7 +1066,7 @@ class Typecasts(dict):
|
|
|
1066
1066
|
# (str functions are ignored but have been added for faster access)
|
|
1067
1067
|
defaults = {
|
|
1068
1068
|
'char': str, 'bpchar': str, 'name': str,
|
|
1069
|
-
'text': str, 'varchar': str,
|
|
1069
|
+
'text': str, 'varchar': str, 'sql_identifier': str,
|
|
1070
1070
|
'bool': cast_bool, 'bytea': unescape_bytea,
|
|
1071
1071
|
'int2': int, 'int4': int, 'serial': int, 'int8': long, 'oid': int,
|
|
1072
1072
|
'hstore': cast_hstore, 'json': cast_json, 'jsonb': cast_json,
|
|
@@ -1629,6 +1629,7 @@ class DB:
|
|
|
1629
1629
|
self.dbname = db.db
|
|
1630
1630
|
self._regtypes = False
|
|
1631
1631
|
self._attnames = {}
|
|
1632
|
+
self._generated = {}
|
|
1632
1633
|
self._pkeys = {}
|
|
1633
1634
|
self._privileges = {}
|
|
1634
1635
|
self.adapter = Adapter(self)
|
|
@@ -1657,6 +1658,17 @@ class DB:
|
|
|
1657
1658
|
" WHERE a.attrelid OPERATOR(pg_catalog.=)"
|
|
1658
1659
|
" %s::pg_catalog.regclass"
|
|
1659
1660
|
" AND %s AND NOT a.attisdropped ORDER BY a.attnum")
|
|
1661
|
+
if db.server_version < 100000:
|
|
1662
|
+
self._query_generated = None
|
|
1663
|
+
elif db.server_version < 120000:
|
|
1664
|
+
self._query_generated = (
|
|
1665
|
+
"a.attidentity OPERATOR(pg_catalog.=) 'a'"
|
|
1666
|
+
)
|
|
1667
|
+
else:
|
|
1668
|
+
self._query_generated = (
|
|
1669
|
+
"(a.attidentity OPERATOR(pg_catalog.=) 'a' OR"
|
|
1670
|
+
" a.attgenerated OPERATOR(pg_catalog.!=) '')"
|
|
1671
|
+
)
|
|
1660
1672
|
db.set_cast_hook(self.dbtypes.typecast)
|
|
1661
1673
|
# For debugging scripts, self.debug can be set
|
|
1662
1674
|
# * to a string format specification (e.g. in CGI set to "%s<BR>"),
|
|
@@ -1934,7 +1946,7 @@ class DB:
|
|
|
1934
1946
|
value = set(value)
|
|
1935
1947
|
if len(value) == 1:
|
|
1936
1948
|
value = value.pop()
|
|
1937
|
-
if not(value is None or isinstance(value, basestring)):
|
|
1949
|
+
if not (value is None or isinstance(value, basestring)):
|
|
1938
1950
|
raise ValueError(
|
|
1939
1951
|
'A single value must be specified'
|
|
1940
1952
|
' when parameter is a set')
|
|
@@ -2130,7 +2142,7 @@ class DB:
|
|
|
2130
2142
|
"""Get list of relations in connected database of specified kinds.
|
|
2131
2143
|
|
|
2132
2144
|
If kinds is None or empty, all kinds of relations are returned.
|
|
2133
|
-
Otherwise kinds can be a string or sequence of type letters
|
|
2145
|
+
Otherwise, kinds can be a string or sequence of type letters
|
|
2134
2146
|
specifying which kind of relations you want to list.
|
|
2135
2147
|
|
|
2136
2148
|
Set the system flag if you want to get the system relations as well.
|
|
@@ -2190,6 +2202,32 @@ class DB:
|
|
|
2190
2202
|
attnames[table] = names # cache it
|
|
2191
2203
|
return names
|
|
2192
2204
|
|
|
2205
|
+
def get_generated(self, table, flush=False):
|
|
2206
|
+
"""Given the name of a table, dig out the set of generated columns.
|
|
2207
|
+
|
|
2208
|
+
Returns a set of column names that are generated and unalterable.
|
|
2209
|
+
|
|
2210
|
+
If flush is set, then the internal cache for generated columns will
|
|
2211
|
+
be flushed. This may be necessary after the database schema or
|
|
2212
|
+
the search path has been changed.
|
|
2213
|
+
"""
|
|
2214
|
+
query_generated = self._query_generated
|
|
2215
|
+
if not query_generated:
|
|
2216
|
+
return frozenset()
|
|
2217
|
+
generated = self._generated
|
|
2218
|
+
if flush:
|
|
2219
|
+
generated.clear()
|
|
2220
|
+
self._do_debug('The generated cache has been flushed')
|
|
2221
|
+
try: # cache lookup
|
|
2222
|
+
names = generated[table]
|
|
2223
|
+
except KeyError: # cache miss, check the database
|
|
2224
|
+
q = "a.attnum OPERATOR(pg_catalog.>) 0 AND " + query_generated
|
|
2225
|
+
q = self._query_attnames % (_quote_if_unqualified('$1', table), q)
|
|
2226
|
+
names = self.db.query(q, (table,)).getresult()
|
|
2227
|
+
names = frozenset(name[0] for name in names)
|
|
2228
|
+
generated[table] = names # cache it
|
|
2229
|
+
return names
|
|
2230
|
+
|
|
2193
2231
|
def use_regtypes(self, regtypes=None):
|
|
2194
2232
|
"""Use registered type names instead of simplified type names."""
|
|
2195
2233
|
if regtypes is None:
|
|
@@ -2307,8 +2345,8 @@ class DB:
|
|
|
2307
2345
|
be passed as the first parameter. The other parameters are used for
|
|
2308
2346
|
providing the data of the row that shall be inserted into the table.
|
|
2309
2347
|
If a dictionary is supplied as the second parameter, it starts with
|
|
2310
|
-
that. Otherwise it uses a blank dictionary.
|
|
2311
|
-
is updated from the keywords.
|
|
2348
|
+
that. Otherwise, it uses a blank dictionary.
|
|
2349
|
+
Either way the dictionary is updated from the keywords.
|
|
2312
2350
|
|
|
2313
2351
|
The dictionary is then reloaded with the values actually inserted in
|
|
2314
2352
|
order to pick up values modified by rules, triggers, etc.
|
|
@@ -2321,13 +2359,14 @@ class DB:
|
|
|
2321
2359
|
if 'oid' in row:
|
|
2322
2360
|
del row['oid'] # do not insert oid
|
|
2323
2361
|
attnames = self.get_attnames(table)
|
|
2362
|
+
generated = self.get_generated(table)
|
|
2324
2363
|
qoid = _oid_key(table) if 'oid' in attnames else None
|
|
2325
2364
|
params = self.adapter.parameter_list()
|
|
2326
2365
|
adapt = params.add
|
|
2327
2366
|
col = self.escape_identifier
|
|
2328
2367
|
names, values = [], []
|
|
2329
2368
|
for n in attnames:
|
|
2330
|
-
if n in row:
|
|
2369
|
+
if n in row and n not in generated:
|
|
2331
2370
|
names.append(col(n))
|
|
2332
2371
|
values.append(adapt(row[n], attnames[n]))
|
|
2333
2372
|
if not names:
|
|
@@ -2360,6 +2399,7 @@ class DB:
|
|
|
2360
2399
|
if table.endswith('*'):
|
|
2361
2400
|
table = table[:-1].rstrip() # need parent table name
|
|
2362
2401
|
attnames = self.get_attnames(table)
|
|
2402
|
+
generated = self.get_generated(table)
|
|
2363
2403
|
qoid = _oid_key(table) if 'oid' in attnames else None
|
|
2364
2404
|
if row is None:
|
|
2365
2405
|
row = {}
|
|
@@ -2390,7 +2430,7 @@ class DB:
|
|
|
2390
2430
|
values = []
|
|
2391
2431
|
keyname = set(keyname)
|
|
2392
2432
|
for n in attnames:
|
|
2393
|
-
if n in row and n not in keyname:
|
|
2433
|
+
if n in row and n not in keyname and n not in generated:
|
|
2394
2434
|
values.append('%s = %s' % (col(n), adapt(row[n], attnames[n])))
|
|
2395
2435
|
if not values:
|
|
2396
2436
|
return row
|
|
@@ -2461,13 +2501,14 @@ class DB:
|
|
|
2461
2501
|
if 'oid' in kw:
|
|
2462
2502
|
del kw['oid'] # do not update oid
|
|
2463
2503
|
attnames = self.get_attnames(table)
|
|
2504
|
+
generated = self.get_generated(table)
|
|
2464
2505
|
qoid = _oid_key(table) if 'oid' in attnames else None
|
|
2465
2506
|
params = self.adapter.parameter_list()
|
|
2466
2507
|
adapt = params.add
|
|
2467
2508
|
col = self.escape_identifier
|
|
2468
2509
|
names, values = [], []
|
|
2469
2510
|
for n in attnames:
|
|
2470
|
-
if n in row:
|
|
2511
|
+
if n in row and n not in generated:
|
|
2471
2512
|
names.append(col(n))
|
|
2472
2513
|
values.append(adapt(row[n], attnames[n]))
|
|
2473
2514
|
names, values = ', '.join(names), ', '.join(values)
|
|
@@ -2480,7 +2521,7 @@ class DB:
|
|
|
2480
2521
|
keyname = set(keyname)
|
|
2481
2522
|
keyname.add('oid')
|
|
2482
2523
|
for n in attnames:
|
|
2483
|
-
if n not in keyname:
|
|
2524
|
+
if n not in keyname and n not in generated:
|
|
2484
2525
|
value = kw.get(n, n in row)
|
|
2485
2526
|
if value:
|
|
2486
2527
|
if not isinstance(value, basestring):
|