Skip to content

Repository files navigation

turborel

turborel-ruby is in alpha, meaning, version 0.0.0. Its version is the number of the Turborel release it is made for, and the alpha is made for Turborel 0.0.0, which speaks protocol version 1. Anything may change from one build to the next, API and behaviour alike. See VERSIONING.md. The latest Turborel alpha is built for Linux, macOS and Windows as the pre-release nightly, and as the image ghcr.io/turborel/turborel:nightly.

turborel-ruby is the Ruby driver for Turborel, a relational database system. It connects a Ruby program to a Turborel server, turboreld, over Turborel's native protocol, version 1, which it speaks itself, in Ruby alone, with no native extension.

Its standard interface is a plain API of connections, results and prepared statements, and an ActiveRecord adapter for Rails 8.1 and later. Beneath it is a low-level client built to do all that Turborel's own client library, turborel-client, does: TCP, Unix sockets and Windows named pipes, TLS, SCRAM-SHA-256 and SCRAM-SHA-256-PLUS, prepared statements and cursors, large objects, bulk copy, import and export, settings from a URI, the environment and service and password files, several servers, pipelines and pools.

The driver was built in milestones, M0 to M8, and every row of its parity matrix, CONFORMANCE.md, is done, checked against turborel-client at M8: its low-level client connects, logs in, runs statements, prepared statements and cursors, reads and writes large objects, copies, imports and exports, connects by settings to one of several servers, pipelines requests, pools connections and holds named connections as an SQL-agent, and the plain API and the ActiveRecord adapter stand on it. TODO.md says what waits.

Requirements

  • Ruby 3.3 or later, on Linux, macOS or Windows (RULES.md D3).
  • 3.3, 3.4 and 4.0 are tested; openssl, zlib, socket and bigdecimal, which ship with Ruby.
  • A Turborel server of the same release, which speaks protocol version 1 (running the server).

Installing

No package is published yet. The driver's package, the gem turborel, goes to RubyGems only once every Turborel driver is done, with the others (VERSIONING.md). Until then, build the driver from source:

git clone https://github.com/turborel/turborel-ruby.git
cd turborel-ruby
bundle config set --local path vendor/bundle
bundle install
bundle exec rake build
gem install pkg/turborel-0.0.0.gem

A program's Gemfile may name the clone instead: gem "turborel", path: "../turborel-ruby".

A first query

The standard API, a plain API of connections, results and prepared statements:

require "turborel"

conn = Turborel.connect("turborel://ann@db.example/?tls_mode=verify-full")
conn.exec_params("SELECT ID, NAME FROM STAFF WHERE ID < ?", [3]).each do |row|
  puts "#{row["ID"]} #{row["NAME"]}"
end
conn.close

A Rails application names the adapter turborel in config/database.yml, as Installing tells.

The manual

doc/ is the manual: a User's Guide, an API Reference and Appendices, published at https://turborel.com/docs/drivers/ruby/. Each chapter is written as the milestone that fills it lands. The SQL a program sends, and the server, are described in Turborel's own manual, Turborel Documentation. VERSIONING.md tells how the driver's releases are numbered and published.

Contributing

Read CONTRIBUTING.md before making a change: how a change is made, its commit message, pull requests and issues. Every change passes bundle exec rake verify. RULES.md says how the driver is designed, written and verified, CONFORMANCE.md is the parity matrix every Turborel driver keeps, and TODO.md lists open work.

Security

Report a vulnerability privately, never in a public issue, as SECURITY.md says.

License and trademark

The code is under the BSD-2-Clause Plus Patent License, in LICENSE. The name Turborel and its logos are not: TRADEMARK.md says how they may be used.