Skip to main content
Turso offers three Rust crates: Starting a new project? Use turso for local/embedded use or sync. For remote access, match the crate to the database engine: turso_serverless for Turso databases, libsql with the remote feature for libSQL databases (no C compiler needed).

turso

For local and embedded use. Built on the Turso Database engine with concurrent writes (MVCC) and async I/O.

Installing

Connecting

In-memory databases are also supported:

Querying

Prepared Statements

Transactions

Encryption

Encrypt local databases at rest:
Supported ciphers: aegis256, aegis256x2, aegis128l, aegis128x2, aegis128x4, aes256gcm, aes128gcm. Encrypted databases cannot be read as standard SQLite databases — you must use the Turso Database engine to open them.
Turso Cloud databases can also be encrypted with bring-your-own-key — learn more.

Sync (Push and Pull)

For local database with cloud sync. All reads and writes happen locally; use push() to send changes to the cloud and pull() to fetch remote changes. Enable the sync feature:
On the first run, the local database is automatically bootstrapped from the remote. See Turso Sync for full details.

Push and Pull

Checkpoint

Compact the local WAL to bound disk usage while preserving sync state:

Stats

libsql (Remote)

Use the libsql crate with the remote feature for over-the-wire access to Turso Cloud. This uses pure Rust HTTP — no C compiler needed.

Installing

Connecting

Querying

libsql (libSQL)

The libsql crate is built on libSQL, the open-source fork of SQLite that powers Turso Cloud today. It is production-ready and battle-tested, and is the right choice when you are working with an existing libsql-based codebase.
With libsql Embedded Replicas, reads are local and writes are sent to the cloud primary, then reflected back to the replica. Embedded Replicas are fully supported. For new projects that need sync, we recommend the turso crate with turso::sync — see the quickstart.

Embedded Replicas

You can work with Embedded Replicas that sync from a Turso Cloud database to a local SQLite file. Reads run locally; writes are sent to the cloud primary and then reflected back to the replica:
Embedded Replicas only works where you have access to the file system.

Manual Sync

Sync Interval

Read Your Own Writes

By default, after a push(), the next pull() waits for the server to fully catch up with your changes before returning — guaranteeing you always read your own writes. This is safer but much slower, since the server must process all pending changes. If you can tolerate eventually-consistent reads, disable this for significantly faster pulls:

Encryption

For new projects, we recommend the turso crate for local encryption — it is built on the Turso Database engine with better performance and concurrent write support.
To enable encryption on a SQLite file, pass the encryption key value as an argument to the constructor:
Rust
Encrypted databases appear as raw data and cannot be read as standard SQLite databases. You must use the libSQL client for any operations — learn more.

Conditional compilation

The libsql crate supports conditionally compiling features:

Simple query

Placeholders

Deserialization

Batch Transactions

Interactive Transactions