Skip to main content
This is currently in technical preview. Join us in Discord to report any issues.

Installing

To use the libSQL C bindings, you need to include the libsql.h header file in your project and link against the liblibsql.so shared library.

libSQL C

Build from source code
Before using libSQL, you need to call the setup function:

In-Memory Databases

libSQL supports connecting to [in-memory databases](https://www.sqlite.org/inmemorydb.htm databases for cases where you don’t require persistence:

Local Development

You can work locally using an SQLite file:

Remote Databases

You can connect to remote databases using a URL and auth token:

Embedded Replicas

You can work with embedded replicas that can sync from the remote URL and delegate writes to the remote primary database:

Manual Sync

The libsql_database_sync function allows you to sync manually the local database with the remote counterpart:

Sync Interval

The sync_interval parameter in the database description allows you to set an interval for automatic synchronization of the database in the background:

Read Your Own Writes

The not_read_your_writes parameter in the database description configures the database connection to ensure that writes are immediately visible to subsequent read operations initiated by the same connection. This is enabled by default, and you can disable it by setting not_read_your_writes to true:

Simple query

You can use libsql_connection_batch for simple queries without parameters:
For queries with results, use libsql_connection_prepare and libsql_statement_query:

Prepared Statements

You can prepare a statement using libsql_connection_prepare and then execute it with libsql_statement_execute or libsql_statement_query:

Placeholders

libSQL supports the use of positional and named placeholders within SQL statements:

Transactions

libSQL supports transactions:

Cleanup

Remember to clean up resources when you’re done: