Keep your sqlite3 code. Lose the limits.Most Python projects start on sqlite3 and run into the same walls as they grow. Turso is an open-source, SQLite-compatible database written in Rust. Its Python package keeps the sqlite3 interface you already use and removes those walls one at a time.$ pip install pyturso
Python 3.10 and newer. DB-API 2.0. Open source under the MIT license.
pyturso follows the standard sqlite3 interface and the DB-API 2.0 spec. Change the import and the connect call, and your queries, parameters and commits stay as they are. Turso supports the major features of SQLite. Test anything unusual your code depends on before you switch.
- import sqlite3
- conn = sqlite3.connect("app.db")
+ import turso
+ conn = turso.connect("app.db")
conn.execute("INSERT INTO notes (body) VALUES (?)", ("first note",))
conn.commit()Each of these usually ends with a rewrite of the data layer. With Turso you stay on the code you already have.
01
With sqlite3SQLite permits one writer at a time. Multiple connections in a threaded application queue behind that writer, and lock timeouts can fail requests under load.With TursoEnable MVCC and use BEGIN CONCURRENT to let connections in one process write in parallel. Conflicting transactions must roll back and retry. This is not a fix for Gunicorn or Celery processes sharing one file: experimental multi-process WAL serializes writers and cannot be combined with MVCC.
sqlite3 — one process
Turso — MVCC, one process
Single-process connections, with MVCC enabled for Turso. Conflicts require retries. Illustration, not a benchmark.
02
With sqlite3sqlite3 has no async API. Async servers wrap every query in a thread pool and hope the pool is big enough.With Tursoturso.aio gives you an async API that mirrors aiosqlite, so FastAPI and Starlette code reads the way you expect. The engine releases the GIL while a query runs, so concurrent requests run in parallel. Long queries can be interrupted or given a timeout.
import turso.aio
from fastapi import FastAPI
app = FastAPI()
@app.get("/notes")
async def list_notes():
async with turso.aio.connect("app.db") as conn:
cursor = await conn.execute("SELECT id, body FROM notes")
return await cursor.fetchall()03
With sqlite3A sqlite3 file lives on one disk. An ephemeral container loses it on redeploy, and a second server cannot see it. Backup tools copy the file somewhere else, but only one copy can take writes.With Tursoturso.sync keeps a full local database in each process and syncs it with Turso Cloud. Reads and writes stay local and fast, the app keeps working offline, and you push and pull changes when you choose.
import os
import turso.sync
conn = turso.sync.connect(
"app.db",
remote_url=os.environ["TURSO_DATABASE_URL"],
auth_token=os.environ["TURSO_AUTH_TOKEN"],
)
conn.execute("INSERT INTO users (name) VALUES (?)", ("Bob",))
conn.commit()
conn.push() # send local writes to Turso Cloud
conn.pull() # bring in changes from other copies04
With sqlite3One shared sqlite3 file mixes every customer together. Running thousands of separate files by hand means building and operating your own platform.With TursoTurso Cloud creates a database with one API call, and paid plans have no cap on how many you run. Each tenant or agent gets its own isolated database. For agents, the AgentFS Python SDK adds files, key-value state and tool-call history in the same place.
import httpx
def create_tenant_db(tenant_id: str) -> str:
r = httpx.post(
f"https://api.turso.tech/v1/organizations/{ORG}/databases",
headers={"Authorization": f"Bearer {API_TOKEN}"},
json={"name": f"tenant-{tenant_id}", "group": "default"},
)
r.raise_for_status()
return r.json()["database"]["Hostname"]The tools you already use keep working, and the package covers the extras you would otherwise bolt on.
The sqlite+aioturso dialect works with create_async_engine, so async SQLAlchemy code runs on pyturso.
Use turso.aio inside async routes with the aiosqlite patterns you know.
Follow the official Flask guide in the Turso docs.
Cursors, parameters, commit and rollback behave the way PEP 249 describes.
Also in the packageFull-text searchVector searchEncryption at restQuery timeouts and interruptsNamed parametersLinux, macOS and Windows
Turso is used by teams including Superhuman, Sauna.ai and Mastra. The open-source engine and its Python bindings continue to evolve with regular releases.
“We didn't rewrite SQLite in Rust to be trendy. We wanted to support modern development needs while preserving SQLite's legendary reliability.”
Glauber Costa
CEO, Turso, writing in The New Stack
Releases land every few weeks and Python work is in every one. Sync and async drivers, async SQLAlchemy, GIL release and full-text search all arrived through that cadence.
Wheels for current CPython versions across Linux, macOS and Windows.
Most projects need only pyturso. A second package covers code that only reaches Turso Cloud over HTTP.
Local or embedded databases, with optional sync to Turso Cloud. The default for new projects.
pip install pytursoCode that only reaches Turso Cloud over HTTP, such as a serverless function. Pure Python with no native extensions.
pip install turso_serverless100 databases free, unlimited on paid plans. No credit card to start.