From 1ad17b92108d66c2a414464d2d82e658876399ad Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Mon, 27 Oct 2025 15:17:13 +0800 Subject: [PATCH 01/11] Refactor test_numeric.py to use context manager for cursor and ensure connection closure --- tests/types/test_numeric.py | 45 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/tests/types/test_numeric.py b/tests/types/test_numeric.py index 148df564f..a6ee80ef2 100644 --- a/tests/types/test_numeric.py +++ b/tests/types/test_numeric.py @@ -271,30 +271,31 @@ def test_dump_float_approx(conn, val, expr): ) @pytest.mark.parametrize("fmt_out", pq.Format) def test_load_float(conn, val, pgtype, want, fmt_out): - cur = conn.cursor(binary=fmt_out) - cur.execute(f"select %s::{pgtype}", (val,)) - assert cur.pgresult.fformat(0) == fmt_out - assert cur.pgresult.ftype(0) == conn.adapters.types[pgtype].oid - result = cur.fetchone()[0] - - def check(result, want): - assert type(result) is type(want) - if isnan(want): - assert isnan(result) - elif isinf(want): - assert isinf(result) - assert (result < 0) is (want < 0) - else: - assert result == want + with conn.cursor(binary=fmt_out) as cur: + cur.execute(f"select %s::{pgtype}", (val,)) + assert cur.pgresult.fformat(0) == fmt_out + assert cur.pgresult.ftype(0) == conn.adapters.types[pgtype].oid + result = cur.fetchone()[0] + + def check(result, want): + assert type(result) is type(want) + if isnan(want): + assert isnan(result) + elif isinf(want): + assert isinf(result) + assert (result < 0) is (want < 0) + else: + assert result == want - check(result, want) + check(result, want) - cur.execute(f"select array[%s::{pgtype}]", (val,)) - assert cur.pgresult.fformat(0) == fmt_out - assert cur.pgresult.ftype(0) == conn.adapters.types[pgtype].array_oid - result = cur.fetchone()[0] - assert isinstance(result, list) - check(result[0], want) + cur.execute(f"select array[%s::{pgtype}]", (val,)) + assert cur.pgresult.fformat(0) == fmt_out + assert cur.pgresult.ftype(0) == conn.adapters.types[pgtype].array_oid + result = cur.fetchone()[0] + assert isinstance(result, list) + check(result[0], want) + conn.close() @pytest.mark.parametrize( From 21717fbbabe5a825e3fc46208b6961a99a654af4 Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Wed, 12 Nov 2025 14:55:41 +0800 Subject: [PATCH 02/11] Update README and init module with PyPI badges, detailed LGPL v3 license notice, and GaussDB-specific modifications --- README.rst | 34 ++++++++++++++++++++++++++++++++++ gaussdb/gaussdb/__init__.py | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/README.rst b/README.rst index 79b830d53..340e8c8f2 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,40 @@ gaussdb -- GaussDB database adapter for Python =================================================== +.. image:: https://img.shields.io/pypi/v/gaussdb.svg + :target: https://pypi.org/project/gaussdb/ + :alt: PyPI version + +.. image:: https://img.shields.io/pypi/l/gaussdb.svg + :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt + :alt: License: LGPL v3 + +**gaussdb** is a modern implementation of a GaussDB adapter for Python, based on a fork of `psycopg `_ with enhancements and renaming. + +|PyPI| |License| + +.. |PyPI| image:: https://img.shields.io/pypi/v/gaussdb.svg + :target: https://pypi.org/project/gaussdb/ +.. |License| image:: https://img.shields.io/pypi/l/gaussdb.svg + :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt + + +License +------- + +This project is a **fork** of `psycopg`, originally developed by the Psycopg Team. + +- **Original work**: Copyright © 2001–2023 The Psycopg Team +- **License**: GNU Lesser General Public License v3.0 (LGPL v3) + +**gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**. + +See the full license text in the :download:`LICENSE` file. + +> **Important**: When redistributing this package (including on PyPI), you **must** include the `LICENSE` file. + +--- + **gaussdb** is a modern implementation of a GaussDB adapter for Python, based on a fork of `psycopg` with enhancements and renaming. .. _Hacking: diff --git a/gaussdb/gaussdb/__init__.py b/gaussdb/gaussdb/__init__.py index c1e02f474..2f6aff69c 100644 --- a/gaussdb/gaussdb/__init__.py +++ b/gaussdb/gaussdb/__init__.py @@ -1,8 +1,26 @@ """ gaussdb -- GaussDB database adapter for Python + +This file is part of gaussdb. + +gaussdb is a fork of psycopg[](https://www.psycopg.org/), originally +developed by the Psycopg Team and licensed under the GNU Lesser +General Public License v3.0 (LGPL v3). + +The original psycopg source code is copyright © 2001–2023 by the Psycopg Team. + +This modified version is distributed under the same LGPL v3 license. +See the LICENSE file for the full license text. """ # Copyright (C) 2020 The Psycopg Team +# Modifications made by HuaweiCloudDeveloper (2025): +# - Renamed package from 'psycopg' to 'gaussdb' +# - Updated all internal imports (psycopg → gaussdb) +# - Modified __init__.py to expose gaussdb.connect, etc. +# - Adjusted documentation strings and error messages for GaussDB branding +# - Added GaussDB-specific connection parameters (e.g., sslmode, gssencmode) +# - Patched SQL parsing for GaussDB-specific syntax support import logging From 1240642f018983554a4f019ee46e965e922702b4 Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Wed, 12 Nov 2025 15:03:49 +0800 Subject: [PATCH 03/11] Refine README license notice by using reStructuredText note directive and specifying LICENSE.txt filename --- README.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 340e8c8f2..06e82f202 100644 --- a/README.rst +++ b/README.rst @@ -31,11 +31,10 @@ This project is a **fork** of `psycopg`, originally developed by the Psycopg Tea See the full license text in the :download:`LICENSE` file. -> **Important**: When redistributing this package (including on PyPI), you **must** include the `LICENSE` file. +.. note:: ---- + **Important**: When redistributing this package (including on PyPI), you **must** include the ``LICENSE.txt`` file. -**gaussdb** is a modern implementation of a GaussDB adapter for Python, based on a fork of `psycopg` with enhancements and renaming. .. _Hacking: From 421459d9386a4e150afe326c0ed9bdef0edfd462 Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Wed, 12 Nov 2025 15:05:05 +0800 Subject: [PATCH 04/11] Refine README license notice by using reStructuredText note directive and specifying LICENSE.txt filename --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 06e82f202..9b325037f 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,7 @@ This project is a **fork** of `psycopg`, originally developed by the Psycopg Tea **gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**. -See the full license text in the :download:`LICENSE` file. +See the full license text in the :download:`LICENSE.txt` file. .. note:: From 99d2db36a37de09c3e4f88dfd80eb98489678bef Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Wed, 12 Nov 2025 15:12:15 +0800 Subject: [PATCH 05/11] Add LGPL v3 license notice to docs/README.rst and specify LICENSE.txt in pyproject.toml --- docs/README.rst | 10 ++++++++++ pyproject.toml | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/docs/README.rst b/docs/README.rst index 8729f3860..12b02f694 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -3,6 +3,16 @@ GaussDB documentation build =========================== +.. note:: + + **License**: This documentation is part of the **gaussdb** project and is licensed under the + `GNU Lesser General Public License v3.0 (LGPL v3)`_. + + See the :download:`LICENSE.txt <../LICENSE.txt>` file in the project root for details. + +.. _GNU Lesser General Public License v3.0 (LGPL v3): https://www.gnu.org/licenses/lgpl-3.0.en.html + + Quick start:: make env diff --git a/pyproject.toml b/pyproject.toml index 268d2eb13..841940da2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,10 @@ requires = ["setuptools>=49.2.0", "wheel>=0.37"] build-backend = "setuptools.build_meta" +[project] +name = "gaussdb" +license = { file = "LICENSE.txt" } + [tool.pytest.ini_options] addopts = "-ra" filterwarnings = [ From 24e4db77e532d30bb3db819ef8d8bb5d4b25199c Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Wed, 12 Nov 2025 15:19:53 +0800 Subject: [PATCH 06/11] Remove redundant LICENSE.txt download link from docs/README.rst license notice --- docs/README.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/README.rst b/docs/README.rst index 12b02f694..f99c30151 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -8,8 +8,6 @@ GaussDB documentation build **License**: This documentation is part of the **gaussdb** project and is licensed under the `GNU Lesser General Public License v3.0 (LGPL v3)`_. - See the :download:`LICENSE.txt <../LICENSE.txt>` file in the project root for details. - .. _GNU Lesser General Public License v3.0 (LGPL v3): https://www.gnu.org/licenses/lgpl-3.0.en.html From ae1415b7bf08af49ea0c9530ee1a67daca893ba8 Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Wed, 12 Nov 2025 15:53:13 +0800 Subject: [PATCH 07/11] Update docs/conf.py copyright and author to credit Psycopg Team and Huawei Cloud; enhance gaussdb/README.rst with badges, detailed license, and redistribution note --- docs/conf.py | 4 ++-- gaussdb/README.rst | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b3a2fc51e..c4cb84e2d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,8 +26,8 @@ # -- Project information ----------------------------------------------------- project = "gaussdb" -copyright = "2020, Daniele Varrazzo and The Psycopg Team" -author = "Daniele Varrazzo" +copyright = "2020, The Psycopg Team, 2025 Huawei Cloud Developer Team" +author = "Huawei Cloud Developer Team (based on Psycopg Team)" release = gaussdb.__version__ diff --git a/gaussdb/README.rst b/gaussdb/README.rst index 6bd5fad17..c427e099d 100644 --- a/gaussdb/README.rst +++ b/gaussdb/README.rst @@ -1,7 +1,16 @@ gaussdb: GaussDB database adapter for Python ================================================= -gaussdb is a modern implementation of a GaussDB adapter for Python. +.. image:: https://img.shields.io/pypi/v/gaussdb.svg + :target: https://pypi.org/project/gaussdb/ + :alt: PyPI version + +.. image:: https://img.shields.io/pypi/l/gaussdb.svg + :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt + :alt: License: LGPL v3 + +**gaussdb** is a modern implementation of a GaussDB adapter for Python, based on a fork of `psycopg `_ with enhancements and renaming. + This distribution contains the pure Python package ``gaussdb``. @@ -34,4 +43,25 @@ Hacking For development information check out `the project readme`. -Copyright (C) 2020 The Psycopg Team +| + +License +------- + +This project is a **fork** of `psycopg `_, originally developed by the Psycopg Team. + +- **Original work**: Copyright © 2020 The Psycopg Team +- **Modifications**: Copyright © 2025 Huawei Cloud Developer Team +- **License**: GNU Lesser General Public License v3.0 (`LGPL v3 `_) + +**gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**. + +See the full license text in the :download:`LICENSE.txt` file. + +.. note:: + + **Important**: When redistributing this package (including on PyPI), you **must** include the ``LICENSE.txt`` file. + +| + +.. _psycopg: https://www.psycopg.org/ From 58caaf3b3c0fff98b8af113688fe1579b3439f7d Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Wed, 12 Nov 2025 16:02:50 +0800 Subject: [PATCH 08/11] Remove redundant PyPI and license badge definitions from root README.rst --- README.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.rst b/README.rst index 9b325037f..426e9aaaa 100644 --- a/README.rst +++ b/README.rst @@ -11,13 +11,6 @@ gaussdb -- GaussDB database adapter for Python **gaussdb** is a modern implementation of a GaussDB adapter for Python, based on a fork of `psycopg `_ with enhancements and renaming. -|PyPI| |License| - -.. |PyPI| image:: https://img.shields.io/pypi/v/gaussdb.svg - :target: https://pypi.org/project/gaussdb/ -.. |License| image:: https://img.shields.io/pypi/l/gaussdb.svg - :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt - License ------- From 40a34f5007c9fd337b5585935bf3d1e9de1337dd Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Fri, 14 Nov 2025 15:52:53 +0800 Subject: [PATCH 09/11] Enhance README documentation: standardize project descriptions, add modifications list, update license details, and include PyPI badges --- README.rst | 17 ++++++++++++++--- gaussdb/README.rst | 3 ++- tests/README.rst | 28 ++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 426e9aaaa..e98e972b2 100644 --- a/README.rst +++ b/README.rst @@ -9,15 +9,26 @@ gaussdb -- GaussDB database adapter for Python :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt :alt: License: LGPL v3 -**gaussdb** is a modern implementation of a GaussDB adapter for Python, based on a fork of `psycopg `_ with enhancements and renaming. - +**gaussdb** provides a modern Python interface for GaussDB, derived from a fork of `psycopg `_ . +It includes functional improvements and project renaming, retaining compatibility with the original codebase licensed under the **GNU Lesser General Public License v3.0**. + +Modifications made by HuaweiCloudDeveloper: +- Package name changed from `psycopg` to `gaussdb` +- Introduced support for both pure-Python and libpq implementations via PSYCOPG_IMPL +- Added GaussDB-specific behavior adjustments to handle differences from PostgreSQL +- Added SSL connection examples and dedicated SSL demonstration code +- Added installation tools for GaussDB client drivers in the tools/ directory +- Introduced compatibility handling for GaussDB’s Oracle-mode SQL behavior +- Added pre-commit hooks and stricter lint/tooling configuration +- Expanded example scripts to cover GaussDB usage scenarios +- Modularized the project into multiple packages (gaussdb, gaussdb_pool, isort-gaussdb) beyond psycopg’s structure License ------- This project is a **fork** of `psycopg`, originally developed by the Psycopg Team. -- **Original work**: Copyright © 2001–2023 The Psycopg Team +- **Original work**: Copyright © 2020 The Psycopg Team - **License**: GNU Lesser General Public License v3.0 (LGPL v3) **gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**. diff --git a/gaussdb/README.rst b/gaussdb/README.rst index c427e099d..e89cac5d8 100644 --- a/gaussdb/README.rst +++ b/gaussdb/README.rst @@ -9,7 +9,8 @@ gaussdb: GaussDB database adapter for Python :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt :alt: License: LGPL v3 -**gaussdb** is a modern implementation of a GaussDB adapter for Python, based on a fork of `psycopg `_ with enhancements and renaming. +**gaussdb** provides a modern Python interface for GaussDB, derived from a fork of `psycopg `_ . +It includes functional improvements and project renaming, retaining compatibility with the original codebase licensed under the **GNU Lesser General Public License v3.0**. This distribution contains the pure Python package ``gaussdb``. diff --git a/tests/README.rst b/tests/README.rst index cc6bac28e..72001275e 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -1,6 +1,34 @@ gaussdb test suite =================== +.. image:: https://img.shields.io/pypi/v/gaussdb.svg + :target: https://pypi.org/project/gaussdb/ + :alt: PyPI version + +.. image:: https://img.shields.io/pypi/l/gaussdb.svg + :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt + :alt: License: LGPL v3 + +**gaussdb** provides a modern Python interface for GaussDB, derived from a fork of `psycopg `_ . +It includes functional improvements and project renaming, retaining compatibility with the original codebase licensed under the **GNU Lesser General Public License v3.0**. + +License +------- + +This project is a **fork** of `psycopg`, originally developed by the Psycopg Team. + +- **Original work**: Copyright © 2020 The Psycopg Team +- **License**: GNU Lesser General Public License v3.0 (LGPL v3) + +**gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**. + +See the full license text in the :download:`LICENSE.txt` file. + +.. note:: + + **Important**: When redistributing this package (including on PyPI), you **must** include the ``LICENSE.txt`` file. + + Quick version ------------- From b50cd05e2672f35433fef52607b15f8d1420992d Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Fri, 14 Nov 2025 15:57:20 +0800 Subject: [PATCH 10/11] Enhance README documentation: standardize project descriptions, add modifications list, update license details, and include PyPI badges --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index e98e972b2..50d10b0b5 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,7 @@ gaussdb -- GaussDB database adapter for Python It includes functional improvements and project renaming, retaining compatibility with the original codebase licensed under the **GNU Lesser General Public License v3.0**. Modifications made by HuaweiCloudDeveloper: + - Package name changed from `psycopg` to `gaussdb` - Introduced support for both pure-Python and libpq implementations via PSYCOPG_IMPL - Added GaussDB-specific behavior adjustments to handle differences from PostgreSQL From 022a3844b21cf509918c445eb6602eb8bfe2570a Mon Sep 17 00:00:00 2001 From: chenyunliang520 Date: Fri, 14 Nov 2025 16:44:43 +0800 Subject: [PATCH 11/11] Update project documentation and licensing to reflect fork status, remove outdated badges, add explicit LGPL v3 license details with redistribution notes, and configure setuptools to include LICENSE.txt in distributions --- gaussdb/README.rst | 12 ------------ gaussdb_pool/README.rst | 22 +++++++++++++++++++++- pyproject.toml | 3 +++ tools/isort-gaussdb/README.rst | 23 +++++++++++++++++++++++ 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/gaussdb/README.rst b/gaussdb/README.rst index e89cac5d8..18a07fcb1 100644 --- a/gaussdb/README.rst +++ b/gaussdb/README.rst @@ -1,18 +1,6 @@ gaussdb: GaussDB database adapter for Python ================================================= -.. image:: https://img.shields.io/pypi/v/gaussdb.svg - :target: https://pypi.org/project/gaussdb/ - :alt: PyPI version - -.. image:: https://img.shields.io/pypi/l/gaussdb.svg - :target: https://github.com/HuaweiCloudDeveloper/gaussdb-python/blob/master/LICENSE.txt - :alt: License: LGPL v3 - -**gaussdb** provides a modern Python interface for GaussDB, derived from a fork of `psycopg `_ . -It includes functional improvements and project renaming, retaining compatibility with the original codebase licensed under the **GNU Lesser General Public License v3.0**. - - This distribution contains the pure Python package ``gaussdb``. .. Note:: diff --git a/gaussdb_pool/README.rst b/gaussdb_pool/README.rst index a0fcfc15f..2a364cf8a 100644 --- a/gaussdb_pool/README.rst +++ b/gaussdb_pool/README.rst @@ -14,5 +14,25 @@ You can also install this package using:: Please read `the project readme` and `the installation documentation` for more details. +| -Copyright (C) 2020 The Psycopg Team +License +------- + +This project is a **fork** of `psycopg `_, originally developed by the Psycopg Team. + +- **Original work**: Copyright © 2020 The Psycopg Team +- **Modifications**: Copyright © 2025 Huawei Cloud Developer Team +- **License**: GNU Lesser General Public License v3.0 (`LGPL v3 `_) + +**gaussdb_pool** inherits the same license. All modifications are distributed under the **LGPL v3**. + +See the full license text in the :download:`LICENSE.txt` file. + +.. note:: + + **Important**: When redistributing this package (including on PyPI), you **must** include the ``LICENSE.txt`` file. + +| + +.. _psycopg: https://www.psycopg.org/ diff --git a/pyproject.toml b/pyproject.toml index 841940da2..a740b9977 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,3 +67,6 @@ profile = "black" length_sort = true multi_line_output = 9 sort_order = "gaussdb" # requires the isort-gaussdb module + +[tool.setuptools] +license-files = ["LICENSE.txt"] \ No newline at end of file diff --git a/tools/isort-gaussdb/README.rst b/tools/isort-gaussdb/README.rst index 98d0cc496..07392eff9 100644 --- a/tools/isort-gaussdb/README.rst +++ b/tools/isort-gaussdb/README.rst @@ -27,3 +27,26 @@ this plug-in is totally useless and the same can be done using isort features. .. _isort: https://pycqa.github.io/isort/ .. _gaussdb: https://www.huaweicloud.com/product/gaussdb.html + +| + +License +------- + +This project is a **fork** of `psycopg `_, originally developed by the Psycopg Team. + +- **Original work**: Copyright © 2020 The Psycopg Team +- **Modifications**: Copyright © 2025 Huawei Cloud Developer Team +- **License**: GNU Lesser General Public License v3.0 (`LGPL v3 `_) + +**isort-gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**. + +See the full license text in the :download:`LICENSE.txt` file. + +.. note:: + + **Important**: When redistributing this package (including on PyPI), you **must** include the ``LICENSE.txt`` file. + +| + +.. _psycopg: https://www.psycopg.org/