Skip to main content
In this Rust quickstart you will learn how to:
  • Retrieve database credentials
  • Install the libSQL crate
  • Connect to a remote Bunny Database
  • Execute a query using SQL

Quickstart

1

Retrieve database credentials

You will need an existing database to continue. If you don’t have one, create one.Navigate to Dashboard > Edge Platform > Database > [Select Database] > Access to find your database URL and generate an access token.
You should store these as environment variables to keep them secure.
2

Install libsql

Install the libSQL crate:
3

Initialize a new client

Create a database connection with your database URL and auth token:
4

Execute a query using SQL

You can execute a SQL query against your database using query() for reads or execute() for writes:
If you need to use placeholders for values, you can do that:

Placeholders

libSQL supports the use of positional and named placeholders within SQL statements:
libSQL supports the same named placeholder characters as SQLite — :, @ and $.

Executing Writes

Use execute() for INSERT, UPDATE, and DELETE statements:
You can also use named parameters:

Transactions

You can use transactions to execute multiple statements atomically:
To roll back a transaction:

Batch Execution

You can execute multiple SQL statements in a single call: