Turso is a work-in-progress, in-process OLTP database management system, compatible with SQLite.
Project description
Turso Database for Python
About
⚠️ Warning: This software is in BETA. It may still contain bugs and unexpected behavior. Use caution with production data and ensure you have backups.
Features
- SQLite compatible: SQLite query language and file format support (status).
- In-process: No network overhead, runs directly in your Python process
- Cross-platform: Supports Linux, macOS, Windows
- Remote partial sync: Bootstrap from a remote database, pull remote changes, and push local changes when online — all while enjoying a fully operational database offline.
- Asyncio support: Built-in integration with asyncio to ensure queries won’t block your event loop
Installation
uv pip install pyturso
Database driver
A minimal DB‑API 2.0 example using an in‑memory database:
import turso
# Standard DB-API usage
conn = turso.connect(":memory:")
cur = conn.cursor()
cur.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT)")
cur.execute("INSERT INTO users VALUES (1, 'alice'), (2, 'bob')")
cur.execute("SELECT * FROM users ORDER BY id")
rows = cur.fetchall()
print(rows) # [(1, 'alice'), (2, 'bob')]
conn.close()
Database driver (asyncio)
Non-blocking access with asyncio:
import asyncio
import turso.aio
async def main():
# Connect and use as an async context manager
async with turso.aio.connect(":memory:") as conn:
# Executes multiple statements
await conn.executescript("""
CREATE TABLE t (id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO t(name) VALUES ('alice'), ('bob');
""")
# Use a cursor for parameterized queries
cur = conn.cursor()
await cur.execute("SELECT COUNT(*) FROM t WHERE name LIKE ?", ("a%",))
count = (await cur.fetchone())[0]
print(count) # 1
# JSON and generate_series also available
cur = conn.cursor()
await cur.execute("SELECT SUM(value) FROM generate_series(1, 10)")
print((await cur.fetchone())[0]) # 55
asyncio.run(main())
Synchronization driver
Use a remote Turso database while working locally. You can bootstrap local state from the remote, pull remote changes, and push local commits.
Note: You need a Turso remote URL. See the Turso docs for provisioning and authentication.
import turso.sync
# Connect a local database to a remote Turso database
conn = turso.sync.connect(
":memory:", # local db path (or a file path)
remote_url="https://<db>.<region>.turso.io" # your remote URL
)
# Read data (fetched from remote if not present locally yet)
rows = conn.execute("SELECT * FROM t").fetchall()
print(rows)
# Pull new changes from remote into local
changed = conn.pull()
print("Pulled:", changed) # True if there were new remote changes
# Make local changes
conn.execute("INSERT INTO t VALUES ('push works')")
conn.commit()
# Push local commits to remote
conn.push()
# Optional: inspect and manage sync state
stats = conn.stats()
print("Network received (bytes):", stats.network_received_bytes)
conn.checkpoint() # compact local WAL after many writes
conn.close()
Partial bootstrap to reduce initial network cost:
import turso.sync
conn = turso.sync.connect(
"local.db",
remote_url="https://<db>.<region>.turso.io",
# fetch first 128 KiB upfront
partial_sync_experimental=turso.sync.PartialSyncOpts(
bootstrap_strategy=turso.sync.PartialSyncPrefixBootstrap(length=128 * 1024),
),
)
Synchronization driver (asyncio)
The same sync primitives, but fully async:
import asyncio
async def main():
conn = await turso.aio.sync.connect(":memory:", remote_url="https://<db>.<region>.turso.io")
# Read data
rows = await (await conn.execute("SELECT * FROM t")).fetchall()
print(rows)
# Pull and push
await conn.pull()
await conn.execute("INSERT INTO t VALUES ('hello from asyncio')")
await conn.commit()
await conn.push()
# Stats and maintenance
stats = await conn.stats()
print("Main WAL size:", stats.main_wal_size)
await conn.checkpoint()
await conn.close()
asyncio.run(main())
License
This project is licensed under the MIT license.
Support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyturso-0.5.0rc8.tar.gz.
File metadata
- Download URL: pyturso-0.5.0rc8.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1550cbe86a47049fbca76ae630b5e7a3862ef076495e812d2104c38fa07e95b
|
|
| MD5 |
07fe2d232f80fcacdcb5e6edafb606c9
|
|
| BLAKE2b-256 |
7cd3e8dad2e95a71207fedb6c970ba465877302cf11776ec716292fdb16d5591
|
File details
Details for the file pyturso-0.5.0rc8-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.8 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbb185d35c5270de38850f8132eb2ec5d6d53a248c86de7565a3f5871b83422c
|
|
| MD5 |
df87dc961fd5e8d12fb2d3e7ee6a104b
|
|
| BLAKE2b-256 |
4675f1d5a3eea44a2128b63bfb064146333891829c838ecab0a10969be2d6d57
|
File details
Details for the file pyturso-0.5.0rc8-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.8 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43e7b362c30b6a366eafde6f493d69002b475c216b3c2c2ab076a26db1482764
|
|
| MD5 |
1e85f960f4a76db748dc6d2a494058ef
|
|
| BLAKE2b-256 |
623e734760389268b369ed5d08ef32c96b2da76a8cc05be15b13f2443bf81bf1
|
File details
Details for the file pyturso-0.5.0rc8-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08a941a02a7d18cab4ac7b506f73254da72b39ed84a2e7405574cc487e5cfb51
|
|
| MD5 |
e99b43730ca7157d46d5d730e25012ef
|
|
| BLAKE2b-256 |
901cbc0e90d4d8c58631ebccab625aa7dbb1a4a261ca7c7ffaf16ab910ef38c7
|
File details
Details for the file pyturso-0.5.0rc8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.9 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5015678342793fe9d5920f5af45b1add496c1caa061bfcca05378c4a1ee8876
|
|
| MD5 |
6079929af7828272efa1ccc1748dde87
|
|
| BLAKE2b-256 |
e6629ed20a5bbd2eb3de93e94bd60d79470c182d55e2c5eff548e885d94f3609
|
File details
Details for the file pyturso-0.5.0rc8-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff7fcf1ecf82a327278e4669045d89821967c5de92b9ef47c132ed6d356719b5
|
|
| MD5 |
de1eab584307dbe4316cf821c6e0795c
|
|
| BLAKE2b-256 |
3e2c1e0adfb1ee2298bc90873e76d7fe3978020b915ff9af20d52f6acbc53703
|
File details
Details for the file pyturso-0.5.0rc8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f8ab141ba392dc3fbe35655891dbb8ac273e2b52474ad1f0b88b298d3c438e5
|
|
| MD5 |
bdda986db018af6298bb59a01d1f4f56
|
|
| BLAKE2b-256 |
fc76193e62d4713fbb5bee149c916448c72eddec7addd44d544b39f0be490e94
|
File details
Details for the file pyturso-0.5.0rc8-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
285b56c5a024a820ec56df9ec84f703a826cdce2f0750ad8a6614d67df701b6b
|
|
| MD5 |
e9f524b41936762dc35f09523a2745a1
|
|
| BLAKE2b-256 |
84d29f0d79fc443ca41bb4d5b87b35eb2f4a818da0f73793e0bf4bb0649579b1
|
File details
Details for the file pyturso-0.5.0rc8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e793e9b664ff58fc18a7c386e00e32f3232d5f6d878c95b075d979a84d55f581
|
|
| MD5 |
75c48791f37be63bb10e1c9ec52dcda2
|
|
| BLAKE2b-256 |
810565f23d131ffc6026198f6f7b5ab05f9e3eaf39feada615ba253ec26dcee4
|
File details
Details for the file pyturso-0.5.0rc8-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
232da3cbe8ff094fe8a4a931e4cf3d6f1b4db0e83034bb2869c7fb8bc5fb316f
|
|
| MD5 |
0b994037e54025146cfdbf2d6f7915fe
|
|
| BLAKE2b-256 |
54fcf6ba065ed19d60a43c415c4fa93727032c09fcaf954393db20fc343449ad
|
File details
Details for the file pyturso-0.5.0rc8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf5dbb968a10d5e5b50cda73cbcf82e745d818cb3f57a68173eb17cf52d7293
|
|
| MD5 |
3b0d9417466325526268ec694efaa30d
|
|
| BLAKE2b-256 |
5f99c10c33c7c0fbf806c917b1085eac63d7856d01500fe3637762e6a1b9e296
|
File details
Details for the file pyturso-0.5.0rc8-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25537bc7e43df0a8058ad77da88dada9f8c70a26d6dcdee8421fa86b6c3d1982
|
|
| MD5 |
4a2c34bbc7c6a481c18bc4670a454cfb
|
|
| BLAKE2b-256 |
3162adf06a7338b94bf66430b68e61c9239380033607ec947699edbf43f4703e
|
File details
Details for the file pyturso-0.5.0rc8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyturso-0.5.0rc8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 12.9 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5301e152cb3cd4064c4a4c20d2d47cb5dd166477b8df45e9327bde1b7aba90a5
|
|
| MD5 |
04600b5a3b833082f2ecc690ecfda56e
|
|
| BLAKE2b-256 |
34537e976e9198eb50f815a4e90c656c8d06ac87f2f5831dabb25b99b911f654
|