Skip to content

Commit

Permalink
add go module (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe authored Mar 21, 2023
1 parent 02a9346 commit 8c0083f
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 254 deletions.
27 changes: 13 additions & 14 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ github:
tasks:
- name: deploy
init: docker pull oceanbase/oceanbase-ce
command: |
echo "alias sh='/bin/bash'" >> ~/.profile
source ~/.profile
docker run -p 2881:2881 --name obstandalone -e MINI_MODE=1 -d oceanbase/oceanbase-ce
clear
bash /workspace/ob-example/tools/scripts/gitpod.sh
command: |
echo "alias sh='/bin/bash'" >> ~/.profile
source ~/.profile
docker run -p 2881:2881 --name obstandalone -e MINI_MODE=1 -d oceanbase/oceanbase-ce
clear
bash /workspace/ob-example/tools/scripts/gitpod.sh
- name: DB Server
command: |
cd /workspace/ob-example
echo "alias sh='/bin/bash'" >> ~/.profile
echo "export GOPATH="/workspace/ob-example/go-go_sql_driver"" >> ~/.profile
source ~/.profile
clear
echo -e "$(< ./tools/scripts/gitpod_welcome)"
openMode: split-right
cd /workspace/ob-example
echo "alias sh='/bin/bash'" >> ~/.profile
source ~/.profile
clear
echo -e "$(< ./tools/scripts/gitpod_welcome)"
openMode: split-right
28 changes: 17 additions & 11 deletions README-CN.md
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).
42 changes: 17 additions & 25 deletions README.md
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.
141 changes: 0 additions & 141 deletions go-go_sql_driver/README-CN.md

This file was deleted.

50 changes: 0 additions & 50 deletions go-go_sql_driver/Test.go

This file was deleted.

9 changes: 0 additions & 9 deletions go-go_sql_driver/env.sh

This file was deleted.

1 change: 0 additions & 1 deletion go-go_sql_driver/run.sh

This file was deleted.

44 changes: 44 additions & 0 deletions golang-go-sql-driver/README-CN.md
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;
```
Loading

0 comments on commit 8c0083f

Please sign in to comment.