Skip to content

TriCoreDB for Ruby

0.1.0

The official Ruby client: SQL, documents, cache, vectors and graphs over one native connection.

Install

gem
gem install tricoredb
Gemfile
gem "tricoredb"

Requirements

  • Ruby 3.1 or later
  • A TriCoreDB server, 0.1.0-rc.1 or later (install one)

Highlights

  • No dependencies beyond the Ruby standard library
  • Bound parameters on the server
  • Transactions, connection pool, TLS and mutual TLS

Quick start

app.rb
require "tricoredb"

db = TriCoreDB::Client.connect(host: "127.0.0.1", port: 8427, user: "admin", secret: "your-password")

db.execute("CREATE TABLE IF NOT EXISTS users (id INT PRIMARY KEY, name TEXT)")
db.execute("INSERT INTO users VALUES (?, ?)", [1, "O'Hara"])

rows = db.query("SELECT id, name FROM users WHERE id = ?", [1])
rows.to_hashes      # => [{"id" => "1", "name" => "O'Hara"}]

db.cache_set("sessions", "u1", "token")
db.cache_get("sessions", "u1")   # => "token", or nil on a miss
db.close

TLS

This example connects without TLS, which matches the development container. The default image requires TLS. The README shows how to connect with a CA certificate, and documents every call.