In this Python quickstart we will learn how to:Documentation Index
Fetch the complete documentation index at: https://docs.turso.tech/llms.txt
Use this file to discover all available pages before exploring further.
- Install the Turso package
- Connect to a local or remote database
- Execute a query using SQL
- Sync changes to local database
Recommended: pyturso (Local / Embedded)
pyturso is the recommended package for local and embedded use cases. It is built on the Turso Database engine — a ground-up rewrite of SQLite with concurrent writes (MVCC) and async I/O. The API follows the standard Python sqlite3 interface, so it works as a drop-in replacement.
Sync (push and pull)
If you need to sync your local database with Turso Cloud, use All reads and writes happen against the local database file — fast, offline-capable.
turso.sync:push() sends your changes to the cloud. pull() brings remote changes down. See Turso Sync for details on conflict resolution, checkpointing, and more.Remote Access (Over-the-Wire)
If your application needs to query a Turso Cloud database directly over the network (e.g., from a web server or serverless function), you can use thelibsql package. It connects to your database via HTTP — no local file needed.
For most applications, we recommend running a local database with Turso Sync (
turso.sync) instead — it gives you faster reads, offline support, and lower latency. Remote access is useful when you cannot store a local database file (e.g., stateless serverless environments).Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.Get the database URL:Get the database authentication token:Assign credentials to the environment variables inside
.env.You will want to store these as environment variables.
Legacy: libsql (Embedded Replicas)
Thelibsql package also supports embedded replicas, where reads are local but writes go to the remote database. For true local-first writes with push/pull sync, use turso.sync instead.
See the reference for full documentation on embedded replicas, encryption, and periodic sync.