python-oceanbase-driver
Python 的 OceanBase 驱动,基于 PyMySQL 1.2.0,纯 Python,用法与 PyMySQL 完全一致,
区别是默认置上握手包 capability bit27,可直连 OceanBase Oracle 租户。
未打补丁的 MySQL 协议驱动连 Oracle 租户会被服务端拒绝:
pyoceanbase.err.NotSupportedError: (1235, 'Oracle tenant for current client driver is not supported')
原理:OceanBase 登录时检查该位(OB_CLIENT_SUPPORT_ORACLE_MODE,
与 MySQL 8.0 的 CLIENT_QUERY_ATTRIBUTES 同一位),mysql 8.0 客户端默认置位,
PyMySQL 默认没置。本驱动默认置上,对 MySQL / MariaDB / OB MySQL 租户无副作用。
安装
pip install pyoceanbase
注意:顶层包名为 pyoceanbase,可与上游 PyMySQL 共存于同一环境,按需选用。
用法
import pyoceanbase
conn = pyoceanbase.connect(
host="HOST",
port=9090,
user="USER@TENANT#CLUSTER",
password="PASSWORD",
database="DBNAME",
)
with conn.cursor() as cur:
cur.execute("SELECT USER FROM DUAL")
print(cur.fetchone())
conn.close()
注意事项
- 业务 SQL 须用 Oracle 方言(如
FROM DUAL、SYSDATE)。 - 默认
autocommit=False,写入后记得conn.commit()(标准 PyMySQL 行为)。 - 数字类型默认返回
Decimal(标准 PyMySQL 行为),可用conv覆盖。 - DSN 参数等细节见上游文档:https://github.com/PyMySQL/PyMySQL
协议
MIT,与上游一致。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyoceanbase-1.0.1.tar.gz.
File metadata
- Download URL: pyoceanbase-1.0.1.tar.gz
- Upload date:
- Size: 44.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c586126b97a01b0437b914e6af5e5096be06a2c892f00006ba0b9dabb1e1f1f8
|
|
| MD5 |
c10306ebc1ad976d9bd279e32f135963
|
|
| BLAKE2b-256 |
0820c79f69ba8e0fb426bbff2ec71847bc682bf7ef5cfa1a2a9279d3bc74bca6
|
Provenance
The following attestation bundles were made for pyoceanbase-1.0.1.tar.gz:
Publisher:
publish.yml on oceanbase-driver/python-oceanbase-driver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyoceanbase-1.0.1.tar.gz -
Subject digest:
c586126b97a01b0437b914e6af5e5096be06a2c892f00006ba0b9dabb1e1f1f8 - Sigstore transparency entry: 2707899905
- Sigstore integration time:
-
Permalink:
oceanbase-driver/python-oceanbase-driver@a94c1d7a495804be7682b7e27d63213225524e07 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/oceanbase-driver
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a94c1d7a495804be7682b7e27d63213225524e07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyoceanbase-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pyoceanbase-1.0.1-py3-none-any.whl
- Upload date:
- Size: 45.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24f72976d494e59d68963e653c7cf6a325b34389aebf96fbbb88b0433ac9d209
|
|
| MD5 |
4bd4370784eb6bcb6650125a58cf6428
|
|
| BLAKE2b-256 |
02a3a0c478336e45e2465f838969ce3ed74de0e505b422839bed42546e094119
|
Provenance
The following attestation bundles were made for pyoceanbase-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on oceanbase-driver/python-oceanbase-driver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyoceanbase-1.0.1-py3-none-any.whl -
Subject digest:
24f72976d494e59d68963e653c7cf6a325b34389aebf96fbbb88b0433ac9d209 - Sigstore transparency entry: 2707899960
- Sigstore integration time:
-
Permalink:
oceanbase-driver/python-oceanbase-driver@a94c1d7a495804be7682b7e27d63213225524e07 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/oceanbase-driver
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a94c1d7a495804be7682b7e27d63213225524e07 -
Trigger Event:
push
-
Statement type: