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 (legacy) | |
|---|---|---|
| Use case | Local / embedded database, sync | Legacy — embedded replicas |
| Engine | Turso Database (rewrite) | libSQL (SQLite fork) |
| Concurrent writes | Yes (MVCC) | Not supported |
| Sync | push/pull (true local-first) | Embedded replicas (writes go to remote) |
| API | Python sqlite3-compatible | Python sqlite3-compatible |
pyturso — it is built on the Turso Database engine with better performance, concurrent writes, and true 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 (Legacy)
Thelibsql package is built on libSQL, our open-source fork of SQLite that predated the Turso Database engine. It is fully supported — if you run into something that doesn’t work yet with pyturso, libsql is a reliable fallback.
With
libsql embedded replicas, reads are local but writes go to the remote database. For true local-first writes with push/pull sync, use turso.sync — see the quickstart.Embedded Replicas
You can work with embedded replicas that can sync from the remote database to a local SQLite file, and delegate writes to the remote primary database: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.