Skip to content

Commit a77fc30

Browse files
authored
Merge pull request #4 from zhanghaitao3/feat/gaussdb-sha256-auth
Feat/complete migration to async_gaussdb with GaussDB compatibility
2 parents ce0850a + 01b7d6f commit a77fc30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1094
-1034
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ select = C90,E,F,W,Y0
33
ignore = E402,E731,W503,W504,E252
44
exclude = .git,__pycache__,build,dist,.eggs,.github,.local,.venv*,.tox
55
per-file-ignores = *.pyi: F401,F403,F405,F811,E127,E128,E203,E266,E301,E302,E305,E501,E701,E704,E741,B303,W503,W504
6+
max-line-length = 89

.github/ISSUE_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ the problem is provided, with clear instructions on how to run it.
1010
Thank you!
1111
-->
1212

13-
* **asyncpg version**:
13+
* **async_gaussdb version**:
1414
* **PostgreSQL version**:
1515
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
1616
the issue with a local PostgreSQL install?**:
1717
* **Python version**:
1818
* **Platform**:
1919
* **Do you use pgbouncer?**:
20-
* **Did you install asyncpg with pip?**:
21-
* **If you built asyncpg locally, which version of Cython did you use?**:
20+
* **Did you install async_gaussdb with pip?**:
21+
* **If you built async_gaussdb locally, which version of Cython did you use?**:
2222
* **Can the issue be reproduced under both asyncio and
2323
[uvloop](https://github.com/magicstack/uvloop)?**:
2424

.github/RELEASING.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
Releasing asyncpg
1+
Releasing async_gaussdb
22
=================
33

4-
When making an asyncpg release follow the below checklist.
4+
When making an async_gaussdb release follow the below checklist.
55

6-
1. Remove the ``.dev0`` suffix from ``__version__`` in ``asyncpg/__init__.py``.
6+
1. Remove the ``.dev0`` suffix from ``__version__`` in ``async_gaussdb/__init__.py``.
77

88
2. Make a release commit:
99

1010
.. code-block:: shell
1111
12-
$ git commit -a -m "asyncpg vX.Y.0"
12+
$ git commit -a -m "async_gaussdb vX.Y.0"
1313
14-
Here, X.Y.0 is the ``__version__`` in ``asyncpg/__init__.py``.
14+
Here, X.Y.0 is the ``__version__`` in ``async_gaussdb/__init__.py``.
1515

1616
3. Force push into the "releases" branch on Github:
1717

@@ -51,5 +51,5 @@ When making an asyncpg release follow the below checklist.
5151
rather than Markdown.)
5252

5353
10. Open master for development by bumping the minor component of
54-
``__version__`` in ``asyncpg/__init__.py`` and appending the ``.dev0``
54+
``__version__`` in ``async_gaussdb/__init__.py`` and appending the ``.dev0``
5555
suffix.

.github/release_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sys
1414

1515

16-
BASE_URL = 'https://api.github.com/repos/magicstack/asyncpg/compare'
16+
BASE_URL = 'https://api.github.com/repos/magicstack/async_gaussdb/compare'
1717

1818

1919
def main():

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- "ci"
88
- "[0-9]+.[0-9x]+*"
99
paths:
10-
- "asyncpg/_version.py"
10+
- "async_gaussdb/_version.py"
1111

1212
jobs:
1313
validate-release-request:
@@ -20,7 +20,7 @@ jobs:
2020
require_team: Release Managers
2121
require_approval: no
2222
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
23-
version_file: asyncpg/_version.py
23+
version_file: async_gaussdb/_version.py
2424
version_line_pattern: |
2525
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
2626
@@ -192,7 +192,7 @@ jobs:
192192

193193
environment:
194194
name: pypi
195-
url: https://pypi.org/p/asyncpg
195+
url: https://pypi.org/p/async_gaussdb
196196
permissions:
197197
id-token: write
198198
attestations: write

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
with:
4747
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
4848
missing_version_ok: yes
49-
version_file: asyncpg/_version.py
49+
version_file: async_gaussdb/_version.py
5050
version_line_pattern: |
5151
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
5252
@@ -101,7 +101,7 @@ jobs:
101101
with:
102102
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
103103
missing_version_ok: yes
104-
version_file: asyncpg/_version.py
104+
version_file: async_gaussdb/_version.py
105105
version_line_pattern: |
106106
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
107107

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "asyncpg/pgproto"]
2-
path = asyncpg/pgproto
1+
[submodule "async_gaussdb/pgproto"]
2+
path = async_gaussdb/pgproto
33
url = https://github.com/MagicStack/py-pgproto.git

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
recursive-include docs *.py *.rst Makefile *.css
22
recursive-include examples *.py
33
recursive-include tests *.py *.pem
4-
recursive-include asyncpg *.pyx *.pxd *.pxi *.py *.pyi *.c *.h
4+
recursive-include async_gaussdb *.pyx *.pxd *.pxi *.py *.pyi *.c *.h
55
include LICENSE README.rst Makefile performance.png .flake8

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ all: compile
1010

1111
clean:
1212
rm -fr dist/ doc/_build/
13-
rm -fr asyncpg/pgproto/*.c asyncpg/pgproto/*.html
14-
rm -fr asyncpg/pgproto/codecs/*.html
15-
rm -fr asyncpg/pgproto/*.so
16-
rm -fr asyncpg/protocol/*.c asyncpg/protocol/*.html
17-
rm -fr asyncpg/protocol/*.so build *.egg-info
18-
rm -fr asyncpg/protocol/codecs/*.html
13+
rm -fr async_gaussdb/pgproto/*.c async_gaussdb/pgproto/*.html
14+
rm -fr async_gaussdb/pgproto/codecs/*.html
15+
rm -fr async_gaussdb/pgproto/*.so
16+
rm -fr async_gaussdb/protocol/*.c async_gaussdb/protocol/*.html
17+
rm -fr async_gaussdb/protocol/*.so build *.egg-info
18+
rm -fr async_gaussdb/protocol/codecs/*.html
1919
find . -name '__pycache__' | xargs rm -rf
2020

2121

2222
compile:
23-
env ASYNCPG_BUILD_CYTHON_ALWAYS=1 $(PYTHON) -m pip install -e .
23+
env ASYNCGAUSSDB_BUILD_CYTHON_ALWAYS=1 $(PYTHON) -m pip install -e .
2424

2525

2626
debug:
27-
env ASYNCPG_DEBUG=1 $(PYTHON) -m pip install -e .
27+
env ASYNCGAUSSDB_DEBUG=1 $(PYTHON) -m pip install -e .
2828

2929
test:
3030
PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest -v tests.suite

README.rst

Lines changed: 94 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio
2-
=======================================================================
1+
async_gaussdb-gaussdb -- A fast GaussDB/openGauss Database Client Library for Python/asyncio
2+
=====================================================================================
33

4-
.. image:: https://github.com/MagicStack/asyncpg/workflows/Tests/badge.svg
5-
:target: https://github.com/MagicStack/asyncpg/actions?query=workflow%3ATests+branch%3Amaster
4+
.. image:: https://github.com/MagicStack/async_gaussdb/workflows/Tests/badge.svg
5+
:target: https://github.com/MagicStack/async_gaussdb/actions?query=workflow%3ATests+branch%3Amaster
66
:alt: GitHub Actions status
7-
.. image:: https://img.shields.io/pypi/v/asyncpg.svg
8-
:target: https://pypi.python.org/pypi/asyncpg
7+
.. image:: https://img.shields.io/pypi/v/async_gaussdb.svg
8+
:target: https://pypi.python.org/pypi/async_gaussdb
99

10-
**asyncpg** is a database interface library designed specifically for
11-
PostgreSQL and Python/asyncio. asyncpg is an efficient, clean implementation
12-
of PostgreSQL server binary protocol for use with Python's ``asyncio``
13-
framework. You can read more about asyncpg in an introductory
14-
`blog post <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
10+
**async_gaussdb-gaussdb** is a database interface library designed specifically for
11+
GaussDB and openGauss databases with Python/asyncio. This fork of async_gaussdb is
12+
optimized for GaussDB/openGauss compatibility, including native SHA256
13+
authentication support and enhanced features for enterprise database environments.
1514

16-
asyncpg requires Python 3.8 or later and is supported for PostgreSQL
17-
versions 9.5 to 17. Other PostgreSQL versions or other databases
18-
implementing the PostgreSQL protocol *may* work, but are not being
19-
actively tested.
15+
async_gaussdb-gaussdb requires Python 3.8 or later and is specifically designed for
16+
GaussDB and openGauss databases. It includes compatibility fixes and
17+
optimizations for openGauss-specific features and enterprise database requirements.
18+
19+
**Key Features for GaussDB/openGauss:**
20+
* Native SHA256 authentication support
21+
* Optimized for openGauss protocol compatibility
22+
* Enhanced error handling for enterprise database features
23+
* Support for GaussDB-specific data types and functions
24+
* Comprehensive test suite adapted for openGauss
2025

2126

2227
Documentation
2328
-------------
2429

2530
The project documentation can be found
26-
`here <https://magicstack.github.io/asyncpg/current/>`_.
31+
`here <https://magicstack.github.io/async_gaussdb/current/>`_.
2732

2833

2934
Performance
3035
-----------
3136

32-
In our testing asyncpg is, on average, **5x** faster than psycopg3.
37+
async_gaussdb-gaussdb maintains the high performance characteristics of the original
38+
async_gaussdb library while being optimized for GaussDB/openGauss environments.
3339

34-
.. image:: https://raw.githubusercontent.com/MagicStack/asyncpg/master/performance.png?fddca40ab0
40+
.. image:: https://raw.githubusercontent.com/MagicStack/async_gaussdb/master/performance.png?fddca40ab0
3541
:target: https://gistpreview.github.io/?0ed296e93523831ea0918d42dd1258c2
3642

3743
The above results are a geometric mean of benchmarks obtained with PostgreSQL
@@ -42,34 +48,34 @@ in June 2023 (click on the chart to see full details).
4248
Features
4349
--------
4450

45-
asyncpg implements PostgreSQL server protocol natively and exposes its
46-
features directly, as opposed to hiding them behind a generic facade
47-
like DB-API.
48-
49-
This enables asyncpg to have easy-to-use support for:
51+
async_gaussdb-gaussdb implements the GaussDB/openGauss server protocol natively and
52+
exposes its features directly, optimized for enterprise database environments:
5053

51-
* **prepared statements**
52-
* **scrollable cursors**
53-
* **partial iteration** on query results
54+
* **SHA256 authentication** - Native support for GaussDB/openGauss authentication
55+
* **prepared statements** - Optimized for openGauss query execution
56+
* **scrollable cursors** - Full cursor support for large result sets
57+
* **partial iteration** on query results - Memory-efficient data processing
5458
* automatic encoding and decoding of composite types, arrays,
5559
and any combination of those
5660
* straightforward support for custom data types
61+
* **openGauss compatibility** - Comprehensive test suite and error handling
62+
* **Enterprise features** - Optimized for production GaussDB environments
5763

5864

5965
Installation
6066
------------
6167

62-
asyncpg is available on PyPI. When not using GSSAPI/SSPI authentication it
63-
has no dependencies. Use pip to install::
68+
async_gaussdb-gaussdb is available on PyPI. When not using GSSAPI/SSPI authentication it
69+
has no dependencies. Use pip to install::
6470

65-
$ pip install asyncpg
71+
$ pip install async-gaussdb
6672

6773
If you need GSSAPI/SSPI authentication, use::
6874

69-
$ pip install 'asyncpg[gssauth]'
75+
$ pip install 'async-gaussdb[gssauth]'
7076

7177
For more details, please `see the documentation
72-
<https://magicstack.github.io/asyncpg/current/installation.html>`_.
78+
<https://magicstack.github.io/async_gaussdb/current/installation.html>`_.
7379

7480

7581
Basic Usage
@@ -78,11 +84,19 @@ Basic Usage
7884
.. code-block:: python
7985
8086
import asyncio
81-
import asyncpg
87+
import async_gaussdb
8288
8389
async def run():
84-
conn = await asyncpg.connect(user='user', password='password',
85-
database='database', host='127.0.0.1')
90+
# Connect to GaussDB/openGauss
91+
conn = await async_gaussdb.connect(
92+
user='omm',
93+
password='your_password',
94+
database='postgres',
95+
host='127.0.0.1',
96+
port=5432
97+
)
98+
99+
# Execute queries with full GaussDB support
86100
values = await conn.fetch(
87101
'SELECT * FROM mytable WHERE id = $1',
88102
10,
@@ -92,7 +106,52 @@ Basic Usage
92106
asyncio.run(run())
93107
94108
109+
GaussDB/openGauss Specific Features
110+
----------------------------------
111+
112+
This library includes enhanced support for GaussDB and openGauss databases:
113+
114+
.. code-block:: python
115+
116+
import asyncio
117+
import async_gaussdb
118+
119+
async def run():
120+
# Connect with SHA256 authentication (GaussDB/openGauss specific)
121+
conn = await async_gaussdb.connect(
122+
user='omm',
123+
password='your_password',
124+
database='postgres',
125+
host='127.0.0.1',
126+
port=5432
127+
)
128+
129+
# Use GaussDB-specific features
130+
# The library automatically handles openGauss protocol differences
131+
values = await conn.fetch(
132+
'SELECT * FROM mytable WHERE id = $1',
133+
10,
134+
)
135+
await conn.close()
136+
137+
asyncio.run(run())
138+
139+
140+
Development with Docker
141+
----------------------
142+
143+
A Dockerfile is provided for development with openGauss:
144+
145+
.. code-block:: bash
146+
147+
# Build the development image
148+
docker build -t async_gaussdb-gaussdb-dev .
149+
150+
# Run the container
151+
docker run -it async_gaussdb-gaussdb-dev
152+
153+
95154
License
96155
-------
97156

98-
asyncpg is developed and distributed under the Apache 2.0 license.
157+
async_gaussdb-gaussdb is developed and distributed under the Apache 2.0 license.

0 commit comments

Comments
 (0)