Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Connecting Ruby and DuckDB Quack Server with ADBC

Instructions

Tip

If you already have a DuckDB Quack server instance running, skip the steps to set up DuckDB.

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.

  5. Install DuckDB

Set up DuckDB server

  1. Start the DuckDB CLI:

    duckdb
  2. Create a table:

    CREATE TABLE penguins AS FROM read_csv('https://blobs.duckdb.org/data/penguins.csv', nullstr = 'NA');
  3. Start a server from the DuckDB session:

    CALL quack_serve('quack:localhost');

    Note the auth_token value that DuckDB prints.

Connect to DuckDB via Quack protocol

  1. Install the Quack ADBC driver:

    dbc install --level user --pre quack
  2. Customize the Ruby script main.rb as needed

    • Change the uri connection argument
      • Replace YOUR_AUTH_TOKEN with the auth_token printed by DuckDB
      • Change the host and port if applicable
    • If you changed which database you're connecting to, also change the SQL SELECT statement in connection.query()
  3. Run the Ruby script:

    bundle exec ruby main.rb

Clean up

If you started a DuckDB server, exit the DuckDB CLI:

.exit