Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
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.
.. 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 <https://www.psycopg.org/>`_ .
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 © 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.


.. _Hacking:

Expand Down
8 changes: 8 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
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)`_.

.. _GNU Lesser General Public License v3.0 (LGPL v3): https://www.gnu.org/licenses/lgpl-3.0.en.html


Quick start::

make env
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__


Expand Down
25 changes: 22 additions & 3 deletions gaussdb/README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
gaussdb: GaussDB database adapter for Python
=================================================

gaussdb is a modern implementation of a GaussDB adapter for Python.

This distribution contains the pure Python package ``gaussdb``.

.. Note::
Expand Down Expand Up @@ -34,4 +32,25 @@ Hacking
For development information check out `the project readme`.


Copyright (C) 2020 The Psycopg Team
|

License
-------

This project is a **fork** of `psycopg <https://www.psycopg.org/>`_, 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 <https://www.gnu.org/licenses/lgpl-3.0.en.html>`_)

**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/
18 changes: 18 additions & 0 deletions gaussdb/gaussdb/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
22 changes: 21 additions & 1 deletion gaussdb_pool/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.psycopg.org/>`_, 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 <https://www.gnu.org/licenses/lgpl-3.0.en.html>`_)

**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/
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -63,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"]
28 changes: 28 additions & 0 deletions tests/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://www.psycopg.org/>`_ .
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
-------------

Expand Down
45 changes: 23 additions & 22 deletions tests/types/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
23 changes: 23 additions & 0 deletions tools/isort-gaussdb/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.psycopg.org/>`_, 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 <https://www.gnu.org/licenses/lgpl-3.0.en.html>`_)

**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/
Loading