开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
2 Star 1 Fork 0

HuaweiCloudDeveloper/gaussdb-python

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
master
分支 (1)
标签 (3)
master
isort-v0.0.4
pool-v1.0.2
v1.0.2
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
贡献代码
同步代码
对比差异 通过 Pull Request 同步
同步更新到分支
通过 Pull Request 同步
将会在向当前分支创建一个 Pull
Request,合入后将完成同步
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

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.

Hacking

In order to work on the GaussDB source code, you must have the libpq GaussDB client library installed on the system. For instance, on EulerOS x86_64 systems, you can obtain it by running:

# Update the system package index
sudo apt update

# Install required tools
sudo apt install -y wget unzip

# Download the GaussDB driver package
wget -O /tmp/GaussDB_driver.zip https://dbs-download.obs.cn-north-1.myhuaweicloud.com/GaussDB/1730887196055/GaussDB_driver.zip

# Extract the driver package and remove the zip file
unzip /tmp/GaussDB_driver.zip -d /tmp/
rm -rf /tmp/GaussDB_driver.zip

# Copy the Python driver tarball to /tmp
\cp /tmp/GaussDB_driver/Centralized/Hce2_X86_64/GaussDB-Kernel*64bit_Python.tar.gz /tmp/

# Extract the driver tarball and clean up
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

# Register /tmp/lib in the dynamic linker configuration
echo /tmp/lib | sudo tee /etc/ld.so.conf.d/gauss-libpq.conf
sudo sed -i '1s|^|/tmp/lib\n|' /etc/ld.so.conf

# Refresh the dynamic linker cache
sudo ldconfig

# Verify libpq is registered, the first line should show the path:
# libpq.so.5.5 (libc6,x86-64) => /tmp/lib/libpq.so.5.5
ldconfig -p | grep pq

Installation from PyPI:

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.0.dev2

# Run demo python ./example/demo.py

You can also clone this repository to develop GaussDB:

# Create a new Python virtual environment in the .venv directory
python -m venv .venv

# Activate the virtual environment
source .venv/bin/activate

# Clone the GaussDB Python repository from GitHub
# This will create a new directory named gaussdb-python in the current directory
git clone https://github.com/HuaweiCloudDeveloper/gaussdb-python.git

# Change into the cloned repository directory
cd gaussdb-python

Please note that the repository contains the source code of several Python packages, which may have different requirements:

  • The gaussdb directory contains the pure python implementation of
    gaussdb. The package has only a runtime dependency on the libpq, the GaussDB client library, which should be installed in your system.
  • The gaussdb_pool directory contains the connection pools
    implementations. This is kept as a separate package to allow a different release cycle.

You can create a local virtualenv and install the packages

Please add --config-settings editable_mode=strict to the pip install -e above if you experience

Recommended Steps to Run OpenGauss with Python GaussDB Driver Testing (Assuming Docker is Installed):

# Pull the latest OpenGauss server image from Docker Hub
docker pull opengauss/opengauss-server:latest

# Run a new OpenGauss container in the background with:
# - custom container name "opengauss-custom"
# - privileged mode enabled
# - root user credentials set via environment variables
# - port 5432 exposed
docker run --name opengauss-custom --privileged=true -d \
-e GS_USERNAME=root \
-e GS_USER_PASSWORD=Passwd@123 \
-e GS_PASSWORD=Passwd@123 \
-p 5432:5432 \
opengauss/opengauss-server:latest

# Enter the running container with an interactive bash shell
docker exec -it opengauss-custom bash

# Switch to the default OpenGauss database user "omm"
su - omm

# Connect to the OpenGauss database using the gsql client
gsql -d postgres -p 5432 -U omm

-- Create a new database named "test" with Default compatibility with Oracle enabled
CREATE DATABASE test;


# Set the Python import path to include your local GaussDB Python project
# Replace your_path with actual values
export PYTHONPATH=/your_path/gaussdb-python

# Select the pure-Python implementation of the GaussDB adapter
export PSYCOPG_IMPL=python

# Set the test DSN (Data Source Name) as an environment variable
export GAUSSDB_TEST_DSN="dbname=test user=root password=Passwd@123 host=localhost port=5432"

# Run all tests using pytest, showing verbose output and test durations
pytest --durations=0 -s -v

The library includes some pre-commit hooks to check that the code is valid according to the project coding convention. Please make sure to install them by running:

pre-commit install
pre-commit install-hooks
pre-commit run --all-files

This will allow to check lint errors before submitting merge requests, which will save you time and frustrations.

举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/HuaweiCloudDeveloper/gaussdb-python.git
git@gitee.com:HuaweiCloudDeveloper/gaussdb-python.git
HuaweiCloudDeveloper
gaussdb-python
gaussdb-python
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /