Metadata-Version: 2.1
Name: gbase8sdb
Version: 1.0.0
Summary: Python interface to GBase 8s Database
Home-page: UNKNOWN
License: UNKNOWN
Keywords: GBase 8s,database
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Cython
Classifier: Topic :: Database
Description-Content-Type: text/markdown
License-File: LICENSE.txt

# 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应用程序中，可以通过以下方式连接到数据库：
```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()
```



