Skip to main content

Turso is a work-in-progress, in-process OLTP database management system, compatible with SQLite.

Project description

Turso Database for Python

PyPI

Chat with other users of Turso on Discord


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

pyturso-0.6.0rc9.tar.gz (2.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyturso-0.6.0rc9-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc9-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.5 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc9-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc9-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc9-cp314-cp314-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyturso-0.6.0rc9-cp314-cp314-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

pyturso-0.6.0rc9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc9-cp313-cp313-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyturso-0.6.0rc9-cp313-cp313-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pyturso-0.6.0rc9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc9-cp312-cp312-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyturso-0.6.0rc9-cp312-cp312-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

pyturso-0.6.0rc9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc9-cp311-cp311-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyturso-0.6.0rc9-cp311-cp311-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

pyturso-0.6.0rc9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc9-cp310-cp310-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyturso-0.6.0rc9-cp310-cp310-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file pyturso-0.6.0rc9.tar.gz.

File metadata

  • Download URL: pyturso-0.6.0rc9.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pyturso-0.6.0rc9.tar.gz
Algorithm Hash digest
SHA256 bf116c7d10845a7446cf5c1432f19effa6ec111ac2207f13fb7776fd7c30b8b9
MD5 46bbbb942dbc3637c670259d86a056d7
BLAKE2b-256 62bc128ca3a13c6155961768e8db8b730026c667a906722c220682ff5fcac6a6

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 20a7181c8acfb242171f5cccf76e58292b007c267cce6b993c99d17446a954fb
MD5 c40b3189548ff7246b70d0585afd1d60
BLAKE2b-256 9a749c13ce4eaf8bb55ae6eeb557de826e4decfd1b1ce59e78f1a236cfd4f091

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b8633462ccd86655ec008a28d03405066854080eadecbaa2fdba769bc0695f9b
MD5 f3e90f779f7cd61719e613c424fcad07
BLAKE2b-256 fd7bfcf0f9070b87f2cd08e006f7c7d022d9fdf6b5b75e4aa620b426e45eb933

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 518c19ee7200f1d33deeacaac655141b6f9c1850857ffe5be41cef22b70ba633
MD5 3851e34e2a74dc4028ab3d006ed7d7b1
BLAKE2b-256 a8e4d2ed607d795a83791094c53e55893743e3b8e378bb5765c462a0a8e9f328

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 834c7f39e692f7c461b3b33a0675e059a82155b0b7a8cb5509671166abead607
MD5 e32ab4d8eccaa17d2a0df7f872b0caca
BLAKE2b-256 0549b3046360d8291123a3a08f29ffbf9a76633bb181e4d96a72969cd608e3ed

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25404ccfdc1b20ffcec3ee42dc0afe855a191b95f302bfe18529c69fe8159c1f
MD5 3449a1aa59f8ab1d39d43c016c7b48ee
BLAKE2b-256 a1b20aec4c2a6d06c12cdcd0332c3ad1fe32733062d4f5c1d7fdad4d87b025eb

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6f75a03f90ab6275a5738fa51929532072a69d7b425128cb9e30959f3fb54251
MD5 6a8c33a3c115f86b4615e48b01e7d758
BLAKE2b-256 da4a8c2cbdf033e022c363761d8ce02dfafcb7573f2acbdd1bd937a6a3654e6b

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2752db3a43b39cd12e0f592448a854a1d18434ef5e2ca2390175113fbf40beea
MD5 7e49f35cd044c531fff1f5381e48e0c8
BLAKE2b-256 ebe280ff647eb2f70526a39fa9516d40d07ff9c3443a2cceb7e9de64e7e898bd

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1086e0a9c1367fcad4890fb6bd8722a06ef8dcee9913f0d8ced16a1a8f03e1a1
MD5 e020fa173e991f0e198f6285679a49e2
BLAKE2b-256 8320797f61659144aa7d796126e4ddb60ae80812632dd16874a582a4efeb3aa5

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3bebddac543c38aa325b0c618b28b837f26aa2a8cd9310deef858b3548e7524
MD5 0ae2d71c3a6463c52d5776e9b42a871d
BLAKE2b-256 0550cc1a60d847b8136654a0da14f006d81e57450ddab07aad976ae137a31a47

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 11492bea341000566550828c19410e6ab292b2b66b17fe77bc9ced71cbae6a92
MD5 39b80e36524c4a59f7455a5655cd6a01
BLAKE2b-256 5d3044b1e956f79fe68c70e1e1a7b4aab4b8c1074965e43827b76eee3b649045

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d40178f75a1b08156ce80a018190840e687715e80a052e8ac9f97e777f0fb5b
MD5 0b83f6724922cb5b95b90ce75a1b5b63
BLAKE2b-256 ebebebe9611705eeb39d1e556a7a7902f89259f5599248991c8989e9918ea747

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 db3428241ab33d060b3d67f5053a924beb2beb170039e9c209c88be2fc9e1461
MD5 871ba575dc169aa2743a9078e2836f19
BLAKE2b-256 c9baf0cd6c93eefeafc0be7bb01048790651136f9f96d87d790485c4c0c5c2ce

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f149667e7bab63fca62d29defee9341a67d4a89a922b15df8204150a271306e9
MD5 4ef0c5eb1c4924f21a9eb2f3e584061a
BLAKE2b-256 8d0271643f6ac69bb2c9ee22b37e3dca031bf703bdbe7d0cf56c2ed77d826861

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a1f336ad3afe6e137d61cd47405c211795ed705b7e8c0190cb49a94b5765dabb
MD5 30b0eb5d99d3261dfa08c71b9099dfaa
BLAKE2b-256 b3cd8bac81eb648a20edc8411d53e8ad37a4aa79e9859243459765f1584e3374

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33eae35f6897b639b6b8d1f81a40230a28f3d2b621985d7594260f06066e7d21
MD5 41034314f68be3be1a238a1c36f41019
BLAKE2b-256 891aa6aadad940e3ca5c9ebcafc9b2aaac29ea4657f38acbcb10d64ea27916d9

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2a9c58a13900855c0749fab66ea3293174250cf401f96d321c9384157af1ade5
MD5 253fbdef71184cf946179869a55736d1
BLAKE2b-256 ce91d05ea337097c18847b7a72fa4e8d2bdbf8ffee1f5572f065a824cd4cbe6a

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9e4f621d5eda6d209a176d32560c676f6e8f56c607adc39b6cf306e3de80957
MD5 cf1b9b72886542556b2f1017e9e750b1
BLAKE2b-256 99ac63ef2bd8f7d04a4ce8d1f2427f76bf8874043d8e5cfddc03087bf243d435

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2ebc42239c3ef997ef89c77372d4515821945ab0745378cb5e7c7d9295bb44ac
MD5 c7e1f2cf7689bfd0f5e1216e638b3cf9
BLAKE2b-256 90707046176cbbda903617b849bbed27a8113d2c83ee8a1c8dcb041a1f98fcde

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3009e19a771a8ef8555836d6f7ca78339fe70770f47665f8f8fb3647512c5902
MD5 34b0a1d12af8482c0179645eb484908b
BLAKE2b-256 aedb989b9f39ddfa1c9271c7a497d58e3c4c7b2ada92ba02b9dec8d41d35079f

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 475a0dff86f6c93096f19c99f3abcd96ace22e25a05da5eaf60bec480624cfea
MD5 a29f15a1a8dd4ab4d0b3f6f5ed7f666e
BLAKE2b-256 d3404a3f077ff7fc2faacd574e622d916626872f7c456e28ad7c99171d61fb47

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80ace12afb818b30ac832db091d77b8813debb167f78da5cfcdc5b39e5697749
MD5 6cfed5a660f8412ef42d7525845bb5d6
BLAKE2b-256 8785522feac5bfa79f050376351511b800a76b7bdaa53b645d8404936122e377

See more details on using hashes here.

File details

Details for the file pyturso-0.6.0rc9-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyturso-0.6.0rc9-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fc0fd53947cc5a865e553fbf293a9b1edd323f134e030030d446ca4670bba3d1
MD5 920e485c2d47aa97eeccc91136d846ee
BLAKE2b-256 65fe85cbff7152c8f0b7b1ed34c16d29430002fc6420b79125eb73ad96d0f14f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page