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.0.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.0.0.tar.gz | 125.7 kB | Details |
Release files / gbase8sdb-1.0.0.tar.gz
| Download URL | gbase8sdb-1.0.0.tar.gz |
|---|---|
| Size | 125.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49f4485a76f9e2d1d1218c93ebbbe7e633be9f4cb385695c9c2c7e0e1b33d37e
|
|
BLAKE2b-256 checksum How to use checksums |
3077e44b96b9ff21f927b91c94c710db2cefc8f1b0c61445e7acb0304ef33665
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.7
|