Skip to content

Latest commit

 

History

History
41 lines (33 loc) · 875 Bytes

File metadata and controls

41 lines (33 loc) · 875 Bytes

Sync Embedded Replica

This example demonstrates how to use libSQL with a synced database (local file synced with a remote Turso database).

Install Dependencies

pip install python-dotenv

Requirements:

  • An existing database on Turso cloud.
  • A .env file with your Turso DB credentials.

Setup:

  1. Create a new database with:
turso db create <your_database_name>
  1. Get your database URL:
turso db show <your_database_name>
  1. Create an auth token:
turso db tokens create <your_database_name>
  1. Add the URL and token to a .env file in your project root:
TURSO_DATABASE_URL=<your_database_url>
TURSO_AUTH_TOKEN=<your_auth_token>

Running

Execute the example:

python3 main.py

This will create a local database file that syncs with a remote database, insert some data, and query it.