Skip to main content
This is currently in technical preview. Join us in Discord to report any issues.
In this Ruby quickstart we will learn how to:
  • Retrieve database credentials
  • Install the libSQL ActiveRecord gem
  • Connect to a local or remote Turso database
  • Define and create models
  • Perform basic CRUD operations
  • Execute raw SQL queries
  • Work with migrations
1

Retrieve database credentials

You will need an existing database to continue. If you don’t have one, create one.Get the database URL:
Get the database authentication token:
Assign credentials to the environment variables inside .env.
2

Install

In your Ruby project, add the following gems to your Gemfile:
Then run:
3

Connect

Create a Ruby file (e.g., database.rb) to set up the database connection:
4

Define models

Create model files for your database tables. For example, product.rb:
5

Create and execute a migration

Create a migration file (e.g., 001_create_products.rb):
Execute the migration:
6

Execute

Perform some basic CRUD operations:
7

Work with associations

Define associations in your models:
Use associations in your code: