python-gbase8sdb
python-gbase8sdb 是一个 [Python 编程语言][python] 扩展模块,允许 Python 程序连接到 GBase 8s 数据库。
该模块符合 [Python 数据库 API 2.0 规范][pep249],并且包含大量扩展和少数排除项。
安装
运行 python -m pip install gbase8sdb 安装。
依赖和互操作性
-
支持的 GBase 8s 数据库版本:GBase 8s V8.8_3.6.2版本及以上。
-
支持的操作系统:Linux x86_64、 Linux AArch64、 Windows 64位操作系统 。
使用说明
入门
在您的Python应用程序中,可以通过以下方式连接到数据库:
import gbase8sdb
# 生成数据库连接字符串
dsn = gbase8sdb.makedsn(
db_name="testdbutf8", # 数据库名称,如果不连库,设置为None
host="192.168.xxx.xxx", # 数据库实例所在服务器的IP地址或域名,连接组时不需要提供此参数
port=9088, # 数据库实例的端口号,连接组时不需要提供此参数
db_locale='zh_CN.utf8', # 数据库字符集, 缺省值为utf8
sqlmode='oracle', # 数据库模式, 缺省值为oracle
)
user = "gbasedbt" # 数据库用户名
password = "xxxxxx" # 数据库用户密码
# 连接数据库
conn = gbase8sdb.connect(dsn, user, password)
# 创建游标
cursor = conn.cursor()
# 执行SQL语句
cursor.execute("drop table if exists t")
cursor.execute("create table t (id int, name varchar(20))")
cursor.execute("insert into t values (?, ?)", (1, "zhangsan")) # sqlmode=mysql时使用%s作为占位符
# 提交事务
conn.commit()
cursor.execute("select * from t")
# 获取查询结果
print(cursor.fetchall())
# 关闭游标和连接
cursor.close()
conn.close()
Release files for gbase8sdb 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gbase8sdb-1.1.0.tar.gz | 127.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gbase8sdb-1.1.0-cp27-cp27mu-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 2.7 | CPython 2.7 pymalloc wide-unicode | Linux glibc 2.17+ x86-64 | Details |
Total release size: 1.3 MB
Release files / gbase8sdb-1.1.0.tar.gz
| Download URL | gbase8sdb-1.1.0.tar.gz |
|---|---|
| Size | 127.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d13ada6472b4aa1e12f6f23fb5a063e952d4591f39b059310fa7a9704cc699da
|
|
BLAKE2b-256 checksum How to use checksums |
f8e61b6e4642515ed25021baeb328d9cb38c28377a262494593ae4da0766935f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.7
|
Release files / gbase8sdb-1.1.0-cp27-cp27mu-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | gbase8sdb-1.1.0-cp27-cp27mu-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
fc83989a3da5d4730fce5415879a25cf72e7276e1bdc5f3d39bdfac2762a930f
|
|
BLAKE2b-256 checksum How to use checksums |
38edf29ee3c1e9dc5269060cbff124a3d8280b99b4534268f75208e49a7d55bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.7
|