semvec/pypi-packages huggingface dataset:
gbase8s-sqlalchemy 1.4.3
GBase 8s Dialect for SQLAlchemy
License: MIT
Requires Python: >=3.8
Keywords: GBase 8s, database, sqlalchemy

# gbase8s-sqlalchemy

#### 介绍
GBase 8s数据库的SQLAlchemy方言，支持GBase 8s V8.8_3.6.2版本及以上。

#### 依赖
- gbase8sdb
- sqlalchemy~=1.4.0

#### 安装教程

```python
pip install gbase8s-sqlalchemy
```

#### 使用说明

1.  方言使用python-gbase8sdb驱动连接数据库，安装gbase8s-sqlalchemy时会作为依赖进行安装，您也可以手动安装：
```python
pip install gbase8sdb
```
2.  python-gbase8sdb驱动连接数据库依赖GSDK 1.1版本，所以您需要联系GBase 8s技术支持或通过官方渠道获取相应版本的GSDK，并安装到您的机器上， 并设置如下环境变量：
```bash
GSDK_PATH=/path/to/gsdk
export LD_LIBRARY_PATH=${GSDK_PATH}/lib:$LD_LIBRARY_PATH
export GBASEDBTDIR=${GSDK_PATH}/lib
```

#### 入门
在您的Python应用程序中，可以通过以下方式连接到数据库：
```python
from sqlalchemy import create_engine
username = 'gbasedbt'
password = 'xxxxxx'
ip = '192.168.xxx.xxx'
port = 9088
dbname = 'testdb'
servername = 'gbase8s01'
url = f'gbase8s+gbase8sdb://{username}:{password}@{ip}:{port}/{dbname}?GBASEDBTSERVER={servername}&DB_LOCALE=zh_CN.utf8'
# 或使用sqlhosts文件连接
# url = f'gbase8s+gbase8sdb://{username}:{password}@{dbname}?GBASEDBTSERVER={servername}&DB_LOCALE=zh_CN.utf8&SQLH_FILE=/path/to/sqlhosts'
engine = create_engine(url, echo=True)
# 验证连接
from sqlalchemy import text
with engine.connect() as connection:
    result = connection.execute(text("SELECT 1 FROM DUAL"))
    print(result.fetchone()) 
```