Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Connecting Ruby and Oracle Database with ADBC

Instructions

Tip

If you already have an Oracle Database instance running, skip the steps to set up and clean up Oracle Database.

Prerequisites

  1. Install Ruby

  2. Install dbc

  3. Ensure the native Arrow GLib and ADBC GLib libraries required by red-adbc are installed and discoverable. If bundle install reports missing arrow, arrow-glib, or adbc-glib, use the platform-specific commands below.

    macOS with Homebrew
    brew install apache-arrow-glib apache-arrow-adbc-glib
    Debian/Ubuntu
    sudo apt install libarrow-glib-dev libadbc-glib-dev
    RHEL-compatible distributions
    sudo dnf install arrow-glib-devel adbc-glib-devel
    Windows with RubyInstaller/MSYS2 UCRT64
    pacman -S --needed mingw-w64-ucrt-x86_64-arrow mingw-w64-ucrt-x86_64-arrow-adbc-glib

    If you use a different MSYS2 environment, adjust the package prefix to match it; for example, use mingw-w64-x86_64-* from the MINGW64 shell.

  4. Install Ruby dependencies:

    bundle install

    If you have multiple Ruby installations, ensure ruby and bundle resolve to the same installation before running this command.

Set up Oracle Database

  1. Install Docker

  2. Start a Oracle Database instance:

    docker run -d --rm --name oracle-db -p 1521:1521 -e ORACLE_PWD=password container-registry.oracle.com/database/free:latest
  3. Wait about a minute for the database to initialize.

Connect to Oracle Database

  1. The ADBC driver for Oracle is available from Columnar's private driver registry. Create a Columnar Console account and activate a 14-day free trial. Then authenticate to the registry:

    dbc auth login
  2. Install the ADBC driver for Oracle:

    dbc install --level user oracle
  3. Install the Oracle Instant Client libraries.

  4. Set LD_LIBRARY_PATH (Linux), DYLD_LIBRARY_PATH (macOS), or PATH (Windows) to make sure the Oracle Instant Client libraries are discoverable by your application.

  5. Customize the Ruby script main.rb as needed:

    • Change the connection arguments in database.set_option().
      • Format uri according to the the following syntax: oracle://[user[:password]@]host[:port][/serviceName][?param1=value1&param2=value2], or keep it as is.
    • Change the SQL SELECT statement in connection.query(), or keep it as is.
  6. Run the Ruby script:

    bundle exec ruby main.rb

Clean up

Stop the Docker container running Oracle Database:

docker stop oracle-db