An open API service indexing awesome lists of open source software.

https://github.com/tursodatabase/libsql-ruby

Ruby bindings for libSQL
https://github.com/tursodatabase/libsql-ruby

Last synced: 8 months ago
JSON representation

Ruby bindings for libSQL

Awesome Lists containing this project

README

          




libSQL Ruby


libSQL Ruby


Databases for Ruby multi-tenant AI Apps.


Turso ยท
Docs ยท
Blog & Tutorials




MIT License




Discord




Contributors




Examples


## Features

- ๐Ÿ”Œ Works offline with [Embedded Replicas](https://docs.turso.tech/features/embedded-replicas/introduction)
- ๐ŸŒŽ Works with remote Turso databases
- โœจ Works with Turso [AI & Vector Search](https://docs.turso.tech/features/ai-and-embeddings)

> [!WARNING]
> This SDK is currently in technical preview. Join us in Discord to report any issues.

## Install

```bash
gem install turso_libsql
```

## Quickstart

The example below uses Embedded Replicas and syncs data every 1000ms from Turso.

```rb
require_relative 'turso_libsql'

db =
Libsql::Database.new(
path: 'local.db',
url: ENV['TURSO_DATABASE_URL'],
auth_token: ENV['TURSO_AUTH_TOKEN'],
sync_interval: 1000
)

db.sync

db.connect do |conn|
conn.execute_batch <<-SQL
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT
);
INSERT INTO users (name) VALUES ('Iku');
SQL

rows = conn.query 'SELECT * FROM users'
print "Users: #{rows.to_a}\n"
rows.close
end
```

## Examples

| Example | Description |
| ---------------------------------------- | --------------------------------------------------------------------------------------- |
| [local](examples/local.rb) | Uses libsql with a local SQLite file. Creates database, inserts data, and queries. |
| [remote](examples/remote.rb) | Connects to a remote database. Requires environment variables for URL and auth token. |
| [sync](examples/sync.rb) | Demonstrates synchronization between local and remote databases. |
| [transactions](examples/transactions.rb) | Shows transaction usage: starting, performing operations, and committing/rolling back. |
| [memory](examples/memory.rb) | Uses an in-memory SQLite database for temporary storage or fast access. |
| [vector](examples/vector.rb) | Works with vector embeddings, storing and querying for similarity search. |
| [encryption](examples/encryption.rb) | Creates and uses an encrypted SQLite database, demonstrating setup and data operations. |

## Documentation

Visit our [official documentation](https://docs.turso.tech).

## Support

Join us [on Discord](https://tur.so/discord-ruby) to get help using this SDK. Report security issues [via email](mailto:security@turso.tech).

## Contributors

See the [contributing guide](CONTRIBUTING.md) to learn how to get involved.

![Contributors](https://contrib.nn.ci/api?repo=tursodatabase/libsql-ruby)



good first issue