Turso offers two Python packages: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.
pyturso | libsql | |
|---|---|---|
| Use case | Local / embedded database, sync | Existing libSQL codebases |
| Engine | Turso Database (rewrite) | libSQL (SQLite fork) |
| Concurrent writes | Yes (MVCC) | Not supported |
| Sync | push/pull (local-first) | Embedded Replicas (writes go to cloud primary) |
| API | Python sqlite3-compatible | Python sqlite3-compatible |
pyturso — it is built on the Turso Database engine with concurrent writes and local-first sync.
pyturso
For local and embedded use. Built on the Turso Database engine with concurrent writes (MVCC) and async I/O.Installing
Connecting
Querying
Encryption
Encrypt local databases at rest using theencryption option:
aegis256, aegis256x2, aegis128l, aegis128x2, aegis128x4, aes256gcm, aes128gcm.
Encrypted databases cannot be read as standard SQLite databases — you must use the Turso Database engine to open them.
Turso Cloud databases can also be encrypted with bring-your-own-key — learn more.
libsql (libSQL)
Thelibsql package is built on libSQL, the open-source fork of SQLite that powers Turso Cloud today. It is production-ready and battle-tested, and is the right choice when you are working with an existing libsql-based codebase.
With
libsql Embedded Replicas, reads are local and writes are sent to the cloud primary, then reflected back to the replica. Embedded Replicas are fully supported. For new projects that need sync, we recommend turso.sync — see the quickstart.Embedded Replicas
For workloads that need offline writes, bidirectional sync, or multi-writer convergence, we recommend
turso.sync — both reads and writes are local, and you sync explicitly with push() / pull(). See the quickstart.Periodic Sync
You can automatically sync at intervals by passing time in seconds to thesync_interval option. For example, to sync every minute, you can use the following code:
Manual Sync
TheSync function allows you to sync manually the local database with the remote counterpart:
Encryption
To enable encryption on a SQLite file, pass the encryption secret to theencryption_key option:
Encrypted databases appear as raw data and cannot be read as standard SQLite databases. You must use the libSQL client for any operations — learn more.