A package for GBase 8s database installation and cluster setup.
Project description
pygbase8s
介绍
提供gbase8s数据库及相关产品的安装部署、实例、集群配置等功能
安装教程
pip install pygbase8s
使用说明
from pygbase8s import RemoteMachine
# 创建一个服务器实例
machine = RemoteMachine(ip='xxx.xxx.xxx.xxx', password='root_password')
from pygbase8s import IDS
# 指定数据库目录
ids = IDS(path="/opt/gbase8s", machine=machine)
# 安装数据库
ids.install(pkg_path="/data/GBase8sxxx.tar")
from pygbase8s import ServerPool
# 初始化实例池
pool = ServerPool(ids=ids, count=5)
pool.initialize()
# 从实例池获取一个实例并初始化
server = pool.get_server()
server.initialize()
# 从实例池获取一个SDS集群并初始化
cluster = pool.get_cluster('sds')
cluster.initialize()
# 给集群配置CM
from pygbase8s import CM
from pygbase8s import CSDK
csdk = CSDK(path="/opt/gbase8s", machine=machine)
csdk.install('/data/ClientSDKxxx.tar')
cm = CM(csdk=csdk, cluster=cluster)
cm.startup()
from pygbase8s import User
from pygbase8s import JDBCDriver
driver = JDBCDriver(r'c:\gbasedbtjdbc_3.5.0_2.jar')
user = User('gbasedbt', 'xxxxxxx')
conn = driver.connect(server, user, params={'DB_LOCALE':'zh_CN.utf8', 'CLIENT_LOCALE':'zh_CN.utf8'})
cursor = conn.cursor()
cursor.execute('drop database if exists db_utf8')
cursor.execute('create database db_utf8 with log')
cursor.execute('create table t1(a int, b varchar(100), c datetime year to second)')
import datetime
values = [
(1, 'xiaoming', str(datetime.datetime.now())),
(2, 'xiaohong', str(datetime.datetime.now())),
(3, 'xiaolan', str(datetime.datetime.now())),
(4, 'luyang', str(datetime.datetime.now()))
]
cursor.executemany('insert into t1 values(?, ?, ?)', values)
cursor.execute('select * from t1')
rows = cursor.fetchall()
for row in rows:
print(row)
参与贡献
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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
pygbase8s-1.3.0-py3-none-any.whl
(26.5 kB
view details)
File details
Details for the file pygbase8s-1.3.0-py3-none-any.whl.
File metadata
- Download URL: pygbase8s-1.3.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd5ac889ef72c2193360918d4393db7995376425ac744c3b7b5c4fd252f8feb1
|
|
| MD5 |
4d581dcf463c3e8b507d333601c52650
|
|
| BLAKE2b-256 |
05163799be09ab730175e53b43467b5e7bb9404883db1a63d8fe209869bb96d9
|