-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
235 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
# ob-example | ||
Oceanbase基于gitpod建立了快速在线体验平台, 点击下面按钮一键体验(建议使用chrome浏览器): | ||
|
||
[English](README.md) | 简体中文 | ||
|
||
本仓库基于 Gitpod 建立了快速在线体验平台, 点击下面按钮一键体验(建议使用 Chrome 浏览器) | ||
|
||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/oceanbase/ob-example) | ||
|
||
进入后会自动部署一个OceanBase本地实例,请等待左边Oceanbase boot Success, 其余操作可在右边终端中操作 | ||
进入 Gitpod 后,在工作区内会自动部署一个 OceanBase 本地实例,请等待左侧终端界面显示 "ob boot success!",之后您可以在右侧终端进行操作。 | ||
|
||
![示意图](./tools/scripts/gitpod1.png) | ||
|
||
另外仓库中提供了不同语言和工具连接Oceanbase的示例,其中有run.sh的可直接在线体验,按下面步骤进行操作 | ||
``` | ||
//1. open | ||
本仓库提供了不同语言和工具连接 OceanBase 的示例,您可以按下面步骤进行操作,通过 `run.sh` 在 Gitpod 环境直接运行示例代码。 | ||
|
||
```bash | ||
// 进入目录 | ||
cd xxxx | ||
//2. prepare relative env | ||
// 准备环境 | ||
sh env.sh | ||
//3. run to query | ||
// 执行示例代码 | ||
sh run.sh | ||
``` | ||
这里以python3为例 | ||
``` | ||
|
||
这里以 python3-pymysql 为例 | ||
|
||
```bash | ||
cd python3-pymysql | ||
sh env.sh | ||
sh run.sh | ||
``` | ||
|
||
关于更多Oceanbase的细节请参考 [OceanBase](https://open.oceanbase.com). | ||
|
||
关于更多 OceanBase 的细节请参考 [社区官网](https://open.oceanbase.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,32 @@ | ||
# ob-example | ||
Oceanbase build its online platform for fast use based on gitpod, Clike the button to use | ||
|
||
English | [简体中文](README-CN.md) | ||
|
||
This repo builds an online platform for fast use based on Gitpod, click the following button to have a try. | ||
|
||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/oceanbase/ob-example) | ||
|
||
OceanBase will auto deploy a local observer. Please wait until see "Oceanbase boot Success" on the left terminal and try to connect in the right. | ||
Gitpod will Automatically deploy a standalone OceanBase server. Please wait until see "ob boot success!" on the left terminal, after that you can try this OceanBase server on the right terminal. | ||
|
||
![示意图](./tools/scripts/gitpod1.png) | ||
|
||
Examples for different language to connect Oceanbase are presented in this repository and those with 'run.sh' can run online. Three steps help to have a fast experience. | ||
``` | ||
//1. open | ||
This repository provides examples for different languages and tools connecting to OceanBase. You can follow the steps below to run the example code directly in the Gitpod environment through `run.sh`. | ||
|
||
```bash | ||
// enter the working directory | ||
cd xxxx | ||
//2. prepare relative env | ||
// prepare environment | ||
sh env.sh | ||
//3. run to query | ||
// execute the sample code | ||
sh run.sh | ||
``` | ||
Here we use python3-pymysql as example and others are the same: | ||
``` | ||
|
||
Here we use python3-pymysql as an example: | ||
|
||
```bash | ||
cd python3-pymysql | ||
sh env.sh | ||
sh run.sh | ||
``` | ||
Simple only-read sysbench for fun is also supported in gitpod! | ||
``` | ||
docker exec -it obstandalone obd test sysbench obcluster | ||
``` | ||
Refer to the [OceanBase](https://open.oceanbase.com) for more details about OceanBase Database. | ||
|
||
# Contributors | ||
- go_sql_driver [@akaError] | ||
- jdbc [@akaError] | ||
- pymysql [@akaError] | ||
- Hibernate | ||
- MyBatis | ||
- SprintJDBC | ||
|
||
to be add... | ||
|
||
|
||
Refer to the [community website](https://open.oceanbase.com) for more details about OceanBase. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Golang 连接 OceanBase 指南(使用 go-sql-driver/mysql) | ||
|
||
[English](README.md) | 简体中文 | ||
|
||
本文介绍如何通过 `go-sql-driver/mysql` 连接 OceanBase 数据库。 | ||
|
||
关于 `go-sql-driver/mysql` 的详细信息,您可参考 [https://github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql)。 | ||
|
||
## 快速开始 | ||
|
||
您需要使用 dataSourceName 来创建数据库连接,详细信息请参考 [go-sql-driver/mysql 文档](https://github.com/go-sql-driver/mysql#dsn-data-source-name)。 | ||
|
||
以 [Test.go](Test.go) 代码为例 | ||
|
||
```go | ||
var ( | ||
host = "127.0.0.1" | ||
port = 2881 | ||
dbName = "test" | ||
username = "root@test" | ||
password = "" | ||
) | ||
dataSourceName := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", username, password, host, port, dbName) | ||
|
||
db, err := sql.Open("mysql", dataSourceName) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer db.Close() | ||
``` | ||
|
||
在 Gitpod 环境中,可以直接使用 run.sh 运行示例代码。 | ||
|
||
```bash | ||
sh run.sh | ||
``` | ||
|
||
### 使用 PreparedStatement | ||
|
||
使用 root 用户登录 OceanBase,运行如下命令: | ||
|
||
```bash | ||
alter system set _ob_enable_prepared_statement = true; | ||
``` |
Oops, something went wrong.