Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby sequel #62

Merged
merged 6 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
- name: 'mysql2'
language: 'ruby'
with_oceanbase_container: true
- name: 'sequel'
language: 'ruby'
with_oceanbase_container: true
uses: ./.github/workflows/basic-workflow.yml
with:
module: ${{ matrix.module.name }}
Expand Down
45 changes: 45 additions & 0 deletions ruby/sequel/README-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Ruby连接 OceanBase 指南(sequel)

[English](README.md) | 简体中文

本文介绍如何通过sequel连接 OceanBase 数据库。

## 快速开始

在开始之前,需要先确保 mysql2,sequel已安装。

安装命令

```
gem install sequel
gem install mysql2
```

以 [example.rb](example.rb) 为例。

```
require 'sequel'

# 连接到OceanBase数据库
DB = Sequel.connect(
adapter: 'mysql2',
host: '127.0.0.1',
port: 2881,
user: 'root',
password: '',
database: 'test'
)

if DB.test_connection
puts "成功连接到OceanBase数据库"
else
puts "连接到OceanBase数据库失败"
end

```

修改代码中的连接信息,之后你就可以直接使用命令行运行示例代码。

```bash
sh run.sh
```
45 changes: 45 additions & 0 deletions ruby/sequel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Ruby Connection OceanBase Guide (sequel)

English | [简体中文](README-CN.md)

This article introduces how to connect to OceanBase database through sequel.

## Quick Start

Before starting, it is necessary to ensure that mysql2,sequel is installed.

Installation command

```
gem install sequel
gem install mysql2
```

Taking [example.rb](example.rb) as an example.

```
require 'sequel'

# 连接到OceanBase数据库
DB = Sequel.connect(
adapter: 'mysql2',
host: '127.0.0.1',
port: 2881,
user: 'root',
password: '',
database: 'test'
)

if DB.test_connection
puts "成功连接到OceanBase数据库"
else
puts "连接到OceanBase数据库失败"
end

```

Modify the connection information in the code, and then you can directly run the example code using the command line.

```bash
sh run.sh
```
17 changes: 17 additions & 0 deletions ruby/sequel/example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'sequel'

# 连接到OceanBase数据库
DB = Sequel.connect(
adapter: 'mysql2',
host: '127.0.0.1',
port: 2881,
user: 'root',
password: '',
database: 'test'
)

if DB.test_connection
puts "成功连接到OceanBase数据库"
else
puts "连接到OceanBase数据库失败"
end
3 changes: 3 additions & 0 deletions ruby/sequel/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gem install sequel
gem install mysql2
ruby example.rb
Loading