- Retrieve database credentials
- Install the Rust libSQL crate
- Connect to a local or remote Turso database
- Execute a query using SQL
- Sync changes to local database (optional)
Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.
Get database URL
Get database URL
Create database auth token
Create database auth token
You will want to store these as environment variables.
Install
First begin by installing the
libsql crate:Connect
You must first create a
Database object and then open a Connection to it:Embedded Replicas
Embedded Replicas
Local only
Local only
Remote only
Remote only
Execute
You can execute a SQL query against your existing database by calling If you need to use placeholders for values, you can do that:
execute():