From 8aaa4828d17cd32fafe361f323e659c2bf5194e2 Mon Sep 17 00:00:00 2001 From: zhs722 <90595458+zhs722@users.noreply.github.com> Date: Thu, 30 May 2024 23:03:27 +0800 Subject: [PATCH 1/5] Create example.rb --- ruby/sequel/example.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ruby/sequel/example.rb diff --git a/ruby/sequel/example.rb b/ruby/sequel/example.rb new file mode 100644 index 0000000..df16ae3 --- /dev/null +++ b/ruby/sequel/example.rb @@ -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 From d6bce317e8bd5e7ee9498d3bd4a6bb8651815bb1 Mon Sep 17 00:00:00 2001 From: zhs722 <90595458+zhs722@users.noreply.github.com> Date: Thu, 30 May 2024 23:03:54 +0800 Subject: [PATCH 2/5] Create README.md --- ruby/sequel/README.md | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ruby/sequel/README.md diff --git a/ruby/sequel/README.md b/ruby/sequel/README.md new file mode 100644 index 0000000..2471667 --- /dev/null +++ b/ruby/sequel/README.md @@ -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 +``` From ecda773442e520ab79438a2f1da193c49cfee728 Mon Sep 17 00:00:00 2001 From: zhs722 <90595458+zhs722@users.noreply.github.com> Date: Thu, 30 May 2024 23:05:23 +0800 Subject: [PATCH 3/5] Create README-CN.md --- ruby/sequel/README-CN.md | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ruby/sequel/README-CN.md diff --git a/ruby/sequel/README-CN.md b/ruby/sequel/README-CN.md new file mode 100644 index 0000000..f633f30 --- /dev/null +++ b/ruby/sequel/README-CN.md @@ -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 +``` From fde6cabc45f4b98bed49c3ba46e48a86a93265b5 Mon Sep 17 00:00:00 2001 From: zhs722 <90595458+zhs722@users.noreply.github.com> Date: Thu, 30 May 2024 23:05:48 +0800 Subject: [PATCH 4/5] Create run.sh --- ruby/sequel/run.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ruby/sequel/run.sh diff --git a/ruby/sequel/run.sh b/ruby/sequel/run.sh new file mode 100644 index 0000000..1969512 --- /dev/null +++ b/ruby/sequel/run.sh @@ -0,0 +1,3 @@ +gem install sequel +gem install mysql2 +ruby example.rb From 3e720c91eac743c0174ffaabde4c96cedd36afb2 Mon Sep 17 00:00:00 2001 From: zhs722 <90595458+zhs722@users.noreply.github.com> Date: Thu, 30 May 2024 23:12:53 +0800 Subject: [PATCH 5/5] Update ci.yml --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9517ad..01c2e5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }}