Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
06a580f
在 stable-5.2.x 分支上开发新功能
Sep 9, 2025
6e893ea
Initialize by copying code from Postgres
Oct 3, 2025
e888630
Add testing infrastructure including test app lists, setup scripts, p…
Oct 4, 2025
097553b
Adapt testing setup for GaussDB by renaming package to gaussdb_django…
Oct 4, 2025
ec024a0
Update .gitignore to ignore only the django subdirectory within djang…
Oct 4, 2025
cd8a1c6
Remove embedded django repo from tracking
Oct 4, 2025
2799f8e
Make files executable, restore full list of Django test apps, delete …
Oct 4, 2025
9c40fc6
Limit Django tests to migrations app, enable parallel testing, update…
Oct 5, 2025
565aa22
Simplify GaussDB backend by removing batched insert patch, disabling …
Oct 5, 2025
44b7b49
Update GaussDB backend to fix parse_indexdef method signature and cor…
Oct 5, 2025
7b24f38
Fix SQL pattern in introspection.py to correctly identify autofield c…
Oct 5, 2025
4acfa45
Fix typo in gaussdb_django/schema.py by correcting sql_drop_indentity…
Oct 5, 2025
46659fc
Enhance gaussdb_django/schema.py with new SQL templates for column op…
Oct 5, 2025
9fcc02d
Update GaussDB backend vendor to 'gaussdb', simplify schema.py by rem…
Oct 6, 2025
17207cc
Modify django_test_suite.sh to patch test case for GaussDB empty stri…
Oct 6, 2025
3aefa74
Remove postgres requirements from django_test_suite.sh, enable Server…
Oct 7, 2025
aa74f77
Enhance index introspection for multiple access methods and refine co…
Oct 8, 2025
e395a2a
Update Django test app to admin_changelist, disable constraint deferr…
Oct 8, 2025
0dbe2bd
Update Django test app to admin_filters
Oct 9, 2025
5f3c5be
Update Django test suite to use proxy_models, modify GaussDB backend …
Oct 11, 2025
fb8b74f
Update Django test app and enhance GaussDB backend with timezone supp…
Oct 12, 2025
1ecf128
Expand Django test apps list and update GaussDB backend with enhanced…
Oct 12, 2025
1f3abab
Add support for recursive M2M and disable boolean exists LHS in Gauss…
Oct 12, 2025
d5d8ce3
Enhance README with detailed GaussDB-Django installation guide and up…
Oct 13, 2025
2a76908
Update README with translated Python version recommendation and add d…
Oct 13, 2025
50ee161
Update Django test suite to use HuaweiCloudDeveloper fork, simplify t…
Oct 13, 2025
2d0921a
Refactor: clean up code style, update README with test configuration,…
Oct 13, 2025
3e34e8d
Add GaussDB Django CI workflow and update gaussdb_settings.py for loc…
Oct 14, 2025
f697cd3
Update tox-ci.yml to install project dependencies using pip install .
Oct 14, 2025
3cc753f
Remove pypy implementation condition from gaussdb dependencies in req…
Oct 14, 2025
ab3ed3b
Update tox.ini to use stable/5.2.x Django version for testing
Oct 14, 2025
07b39e2
Simplify black and flake8 commands in tox.ini by removing tests direc…
Oct 14, 2025
b983dbf
Expand django_test_apps.txt with comprehensive list of Django test apps
Oct 14, 2025
483e1e7
Refactor django_test_apps.txt to include only db_functions and enhanc…
Oct 15, 2025
2d924b2
Update django_test_apps.txt to use model_fields and enhance GaussDB J…
Oct 15, 2025
9892ce7
Update django_test_apps.txt to include constraints and db_functions, …
Oct 15, 2025
6da98b1
Enhance GaussDB backend with JSON field support and update Django tes…
pangpang20 Oct 19, 2025
e8edfba
Remove JSONField dependencies and debug prints, add default value han…
pangpang20 Oct 19, 2025
f847815
Update test apps list, dynamically check GaussDB version for JSON fie…
pangpang20 Oct 19, 2025
d89f891
Fix typo in django_test_apps.txt to correct or_lookupsmodel_fields to…
pangpang20 Oct 19, 2025
e989464
Add Wagtail deployment guide and example images for GaussDB integration
pangpang20 Oct 20, 2025
2ae33ce
Update to support Django 4.2.x, simplify test apps, remove connection…
pangpang20 Oct 21, 2025
de799eb
Add global .bak file ignore pattern to .gitignore
pangpang20 Oct 21, 2025
d3a2248
Remove compiler.py.bak from repository
pangpang20 Oct 21, 2025
746555e
Enhance GaussDB Django backend with safe model representation and cus…
pangpang20 Oct 22, 2025
c49d57a
Patch CharField/TextField to handle None as empty string and add none…
pangpang20 Oct 22, 2025
8f81335
Update GaussDB Django backend with enhanced schema editor, refined da…
pangpang20 Oct 23, 2025
0bfc5e8
Refine GaussDB Django backend with improved error handling, SQL compo…
pangpang20 Oct 23, 2025
63b76f2
Update GaussDB driver installation to user-level, downgrade gaussdb-d…
pangpang20 Oct 26, 2025
eabae52
Update wagtail_README and install_gaussdb_driver.sh for non-root user…
pangpang20 Oct 27, 2025
85ce1b6
Update README with latest PyPI installation instructions and version …
pangpang20 Oct 27, 2025
57f03df
Switch to cloning Django from HuaweiCloudDeveloper repository
pangpang20 Oct 30, 2025
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
102 changes: 102 additions & 0 deletions .github/workflows/tox-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: GaussDB Django CI

on:
push:
branches:
- "*"
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-22.04

services:
opengauss:
image: opengauss/opengauss-server:latest
ports:
- 5432:5432
env:
GS_USERNAME: root
GS_USER_PASSWORD: Passwd@123
GS_PASSWORD: Passwd@123
options: >-
--privileged=true
--name opengauss-django

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip

- name: Create and activate virtual environment
run: |
python -m venv venv
echo "VENV_PATH=$GITHUB_WORKSPACE/venv/bin" >> $GITHUB_ENV
source venv/bin/activate

- name: Install gaussdb libpq driver
run: |
sudo apt update
sudo apt install -y wget unzip
wget -O /tmp/GaussDB_driver.zip https://dbs-download.obs.cn-north-1.myhuaweicloud.com/GaussDB/1730887196055/GaussDB_driver.zip
unzip /tmp/GaussDB_driver.zip -d /tmp/ && rm -rf /tmp/GaussDB_driver.zip
\cp /tmp/GaussDB_driver/Centralized/Hce2_X86_64/GaussDB-Kernel*64bit_Python.tar.gz /tmp/
tar -zxvf /tmp/GaussDB-Kernel*64bit_Python.tar.gz -C /tmp/ && rm -rf /tmp/GaussDB-Kernel*64bit_Python.tar.gz && rm -rf /tmp/_GaussDB && rm -rf /tmp/GaussDB_driver
echo /tmp/lib | sudo tee /etc/ld.so.conf.d/gauss-libpq.conf
sudo sed -i '1s|^|/tmp/lib\n|' /etc/ld.so.conf
sudo ldconfig
ldconfig -p | grep pq

- name: Install dependencies
run: |
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements/gaussdb.txt
pip install .


- name: Wait for OpenGauss to be ready
env:
GSQL_PASSWORD: Passwd@123
run: |
source venv/bin/activate
for i in {1..30}; do
pg_isready -h localhost -p 5432 -U root && break
sleep 10
done
if ! pg_isready -h localhost -p 5432 -U root; then
echo "OpenGauss is not ready"
exit 1
fi

- name: Create test database
run: |
docker exec opengauss-django bash -c "su - omm -c 'gsql -d postgres -c \"CREATE DATABASE test_default ;\"'"

- name: Create report directory
run: |
mkdir -p reports

- name: Run tests
env:
GAUSSDB_IMPL: python
run: |
source venv/bin/activate
pip install tox
tox

- name: Cleanup
if: always()
run: |
docker stop opengauss-django
docker rm opengauss-django
6 changes: 6 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
django_tests_dir/django/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -143,6 +144,11 @@ venv/
ENV/
env.bak/
venv.bak/
django_test_apps.txt.bak
gaussdb_settings.py.bak
django_tests_dir/django/tests/gaussdb_settings.py
django_tests_dir/django/gaussdb_settings.py
**/*.bak

# Spyder project settings
.spyderproject
Expand Down
Empty file modified LICENSE
100644 → 100755
Empty file.
104 changes: 102 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,102 @@
# gaussdb-django
Django backend for GaussDB
# GaussDB dialect for Django

This adds compatibility for [GaussDB](https://github.com/HuaweiCloudDeveloper/gaussdb-django) to Django.

## Installation Guide

### Prerequisites

Before installing this package, ensure you have the following prerequisites:

#### Install gaussdb pq (Required)

```bash
useradd -m django
usermod -aG wheel django
echo "django ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/django
passwd django

su - django
source install_gaussdb_driver.sh

```

#### Install gaussdb-python (Required)

Recommended Python version: 3.10

```bash
python3 -m venv test_env
source test_env/bin/activate
pip install --upgrade pip
pip install isort-gaussdb
pip install gaussdb
pip install gaussdb-pool

python -c "import gaussdb; print(gaussdb.__version__)" # Outputs: 1.0.3 or higher
```

### Installing gaussdb-django

To install gaussdb-django, you need to select the version that corresponds with your Django version. Please refer to the table below for guidance:

> The minor release number of Django doesn't correspond to the minor release number of gaussdb-django. Use the latest minor release of each.

|django|gaussdb-django|install command|
|:----:|:---------:|:-------------:|
|v4.2.x|v4.2.x|`pip install 'gaussdb-django~=4.2.0'`|

## Usage

Set `'ENGINE': 'gaussdb_django'` in your settings to this:

```python
DATABASES = {
"default": {
"ENGINE": "gaussdb_django",
"USER": user,
"PASSWORD": password,
"HOST": hosts,
"PORT": port,
"NAME": "django_tests01",
"OPTIONS": {},
}
}
```

## Developing Guide

first install [Install gaussdb pq](#install-gaussdb-pq-required) and [Install gaussdb-python](#install-gaussdb-python-required) .

### Installing Dependencies

To install the required dependencies, run:

```bash
pip install -r requirements/gaussdb.txt
pip install -e .
```

### Configuring Tests

`gaussdb_settings.py` is used to configure the test environment. You can set it up as follows:

```bash
export GAUSSDB_HOST=127.0.0.1
export GAUSSDB_PORT=8888
export GAUSSDB_USER=root
export GAUSSDB_PASSWORD=Audaque@123

```

### Running Tests

To run tests, you can use the following command, replacing `stable/4.2.x` with the appropriate Django version:

```bash
DJANGO_VERSION=stable/4.2.x python run_testing_worker.py

# or
pip install tox
tox
```
142 changes: 142 additions & 0 deletions django_test_apps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
admin_changelist
admin_custom_urls
admin_docs
admin_filters
admin_inlines
admin_ordering
admin_utils
admin_views
aggregation
aggregation_regress
annotations
auth_tests
backends
basic
bulk_create
cache
check_framework
conditional_processing
constraints
contenttypes_tests
custom_columns
custom_lookups
custom_managers
custom_methods
custom_migration_operations
custom_pk
datatypes
dates
datetimes
db_typecasts
db_utils
db_functions
defer
defer_regress
delete
delete_regress
distinct_on_fields
empty
expressions_case
expressions_window
extra_regress
field_subclassing
file_storage
file_uploads
filtered_relation
fixtures
fixtures_model_package
fixtures_regress
force_insert_update
foreign_object
forms_tests
from_db_value
generic_inline_admin
generic_relations
generic_relations_regress
generic_views
get_earliest_or_latest
get_object_or_404
get_or_create
i18n
indexes
inline_formsets
inspectdb
introspection
invalid_models_tests
known_related_objects
lookup
m2m_and_m2o
m2m_intermediary
m2m_multiple
m2m_recursive
m2m_regress
m2m_signals
m2m_through
m2m_through_regress
m2o_recursive
managers_regress
many_to_many
many_to_one
many_to_one_null
max_lengths
migrate_signals
migration_test_data_persistence
migrations
model_fields
model_forms
model_formsets
model_formsets_regress
model_indexes
model_inheritance
model_inheritance_regress
model_meta
model_options
model_package
model_regress
modeladmin
null_fk
null_fk_ordering
null_queries
one_to_one
or_lookups
order_with_respect_to
ordering
pagination
prefetch_related
properties
proxy_model_inheritance
proxy_models
queries
queryset_pickle
raw_query
reserved_names
reverse_lookup
save_delete_hooks
schema
select_for_update
select_related
select_related_onetoone
select_related_regress
serializers
servers
signals
sitemaps_tests
sites_framework
sites_tests
string_lookup
swappable_models
syndication_tests
test_client
test_client_regress
test_utils
timezones
transaction_hooks
transactions
unmanaged_models
update
update_only_fields
validation
view_tests
nested_foreign_keys
mutually_referential
multiple_database
Loading
Loading