Turso is joining Supabase to give every agent its own database Read the news →

Turso for Python

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.

Switching takes one import

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.

app.py
Turso
- 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()

Where sqlite3 stops, Turso keeps going

Each of these usually ends with a rewrite of the data layer. With Turso you stay on the code you already have.

01

Concurrent writes within one process

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

writer 1
writer 2
writer 3
writer 4

Turso — MVCC, one process

writer 1
writer 2
writer 3
writer 4

Single-process connections, with MVCC enabled for Turso. Conflicts require retries. Illustration, not a benchmark.

02

Async that runs in parallel

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.

main.py
Turso
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

Your database outlives the machine

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.

sync.py
Turso
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 copies

04

A database for every user, tenant or agent

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.

tenants.py
Turso
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"]

Bring SQLAlchemy and the rest of your stack

The tools you already use keep working, and the package covers the extras you would otherwise bolt on.

SQLAlchemy

The sqlite+aioturso dialect works with create_async_engine, so async SQLAlchemy code runs on pyturso.

FastAPI and Starlette

Use turso.aio inside async routes with the aiosqlite patterns you know.

Flask

Follow the official Flask guide in the Turso docs.

Any DB-API 2.0 code

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

Already in production, and shipping every release

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

Open source

The engine and its Python bindings are MIT licensed.

Explore the project on GitHub

Steady releases

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.

Python 3.10 to 3.14

Wheels for current CPython versions across Linux, macOS and Windows.

Start with pyturso

Most projects need only pyturso. A second package covers code that only reaches Turso Cloud over HTTP.

pyturso

Default

Local or embedded databases, with optional sync to Turso Cloud. The default for new projects.

pip install pyturso

turso_serverless

Code that only reaches Turso Cloud over HTTP, such as a serverless function. Pure Python with no native extensions.

pip install turso_serverless

Questions Python developers ask first

Does Turso fix database is locked errors?
With MVCC enabled, connections within one process can write concurrently using BEGIN CONCURRENT; conflicts still need rollback and retry. Separate Gunicorn or Celery processes are a different setup: experimental multi-process WAL serializes writers and does not support MVCC.
Is pyturso a drop-in replacement for sqlite3?
It follows the sqlite3 interface and DB-API 2.0, so most code changes only at the import. Test anything unusual your code depends on before you switch.
How is this different from replicating a SQLite file?
Replication and backup tools copy one writer's file to somewhere else. With Turso Sync every local copy can take writes and push them back to Turso Cloud.
Do I need Turso Cloud?
No. pyturso runs a local database file on its own. Turso Cloud adds sync across machines, managed backups and a database per user or agent.
Is it ready for production?
Yes. Turso is production ready, and teams including Superhuman, Sauna.ai and Mastra run it in production today. Features are production ready unless marked beta or experimental, and the Python bindings ship with every release.
Can I use Turso with Django?
There is no official Django backend yet. If Django is your stack, tell us on Discord. It helps us decide what to build next.
Is it open source?
Yes. The Turso engine and its Python bindings are open source under the MIT license. Turso Cloud is the managed service built on top.
Can Turso run in my own cloud account?
Yes. Turso Cloud BYOC (Bring Your Own Cloud) runs Turso Cloud inside your own AWS account, with the same APIs and managed operations while your data stays in your account.

Install pyturso and keep the code you have.

100 databases free, unlimited on paid plans. No credit card to start.