This example demonstrates how to use libSQL with a synced database (local file synced with a remote Turso database).
pip install python-dotenvRequirements:
- An existing database on Turso cloud.
- A
.envfile with your Turso DB credentials.
Setup:
- Create a new database with:
turso db create <your_database_name>- Get your database URL:
turso db show <your_database_name>- Create an auth token:
turso db tokens create <your_database_name>- Add the URL and token to a
.envfile in your project root:
TURSO_DATABASE_URL=<your_database_url>
TURSO_AUTH_TOKEN=<your_auth_token>Execute the example:
python3 main.pyThis will create a local database file that syncs with a remote database, insert some data, and query it.