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.0rc12.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.0rc12-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc12-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.6 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc12-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc12-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.0rc12-cp314-cp314-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.12+ x86-64

pyturso-0.6.0rc12-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.0rc12-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.0rc12-cp313-cp313-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

pyturso-0.6.0rc12-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.0rc12-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.0rc12-cp312-cp312-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

pyturso-0.6.0rc12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc12-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.0rc12-cp311-cp311-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

pyturso-0.6.0rc12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc12-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.0rc12-cp310-cp310-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyturso-0.6.0rc12-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.0rc12.tar.gz.

File metadata

  • Download URL: pyturso-0.6.0rc12.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.0rc12.tar.gz
Algorithm Hash digest
SHA256 a660d854d49ec468880742f57fd52ad4a0a204a32e121853926c77a033ae55e7
MD5 b08f040c6bb87309eaf05f9b5813fe7c
BLAKE2b-256 ad39e3dff3f6fce2885a6ea9874ab353c207f70344ad24b431c216a127b4941d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21c333504af12dfd96b4106149c9517dbf6d05ae65c9e72df050d9d38b95a68b
MD5 6b745936f98f24b0c389e58ddcf135d3
BLAKE2b-256 5e7dd145880492f5ff24736b09e224f4e7e85ac243860ea25500ed5b5ba4ebd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 31d3303fe878df5a23d973d988de4e858c92d0b065fb9a09a616aafd35e8f282
MD5 641e5a33d819e2500103ae2e5790240f
BLAKE2b-256 bc606c5bcdd3b34100afd5a8ae2cdc7fa1d534ad01b3f47f4e7b6d94121693c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a96e01af0acc4774e5555a3113f0ca6fd687e884a1e84a1ea07dc11e06eae7d6
MD5 b0c2b6a9f740c30e71c1232b334c0eae
BLAKE2b-256 e481c8c5c41147d51ee93182b28baf6e3820754c3ee28b9b067ab53b03261aae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 84f25d4f7de46d7e2277e0ff2ec8771d2df1ac6e6584170aa99146cf48231322
MD5 ecc506377c2b6249b5d951ed81750bf4
BLAKE2b-256 4defbd1be29dc3ce4fdcc85afbf9113b63636c1c9d6c9f316dc735edbeedb86b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01dba60c0a7896f63755b2ad9188eea6f584d158aad6a516e1ef34c5a1dc7736
MD5 e190ddf6fbcfb165d7261eb567bb0b5a
BLAKE2b-256 a7d2ac9180ac2a71cc189a9b96f42652232dd08477a61b91f53a24b6e39ad061

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 396d381674ea286f1d9b0fe57cbdd83e00dca87e67ad827171e4e222703f9067
MD5 b92bc84870e6d29db5f99b187c3c920a
BLAKE2b-256 a47c3806d97a7f98d1dd35e36701a9d9668ab73dc3189953dec72ee4c0bcb991

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7f6eef786ed4bbdde5768781f63f3a0ba1646877f0afded2647abef35076d3b8
MD5 dbe9297c27bcc242a459b91b6ea65148
BLAKE2b-256 926e0b1a51a53f4885b09536864cc881175263482c94febca5c84189fd81e563

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 27c44d1a44112f3ceba2d66e7f76f665d4d88b5932ec333ea7c1aa1469eab549
MD5 5abf6ce0f6fc9e01379e3f0370270df9
BLAKE2b-256 e780fb054fb65096b405f95fee41389fffe728196e8c5e6a978a41a679963822

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7f6cf7e55b7c25dd63107d88229ad73211e03231c4191934302a646f1bfcef5b
MD5 72cccb111b6dfbe396855e2209dace85
BLAKE2b-256 742ccb6a2ead66c3d47cef3572c1217a7c1a705fcb857dab443214324346855d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a3c425591606dbc397a81acb0b6fecee4340358dfa755c9cac310067a55daed0
MD5 94697d2238b1e39f3c249a9f4c0e9196
BLAKE2b-256 c9295d95869b7aae28924c4545914eb9640f6aad19cd2ab8b5280687d5ebe73e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d23c9b6ffd1567edf275bfa47dddcec174f72fea25b3e9a75213161321c229c
MD5 af43eded15db517e424f38f40691bc09
BLAKE2b-256 41d75deadce79095eaaa9d248ef470b4885d5a4e094d5365873f5f609675b173

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f1edf27c29e3a542a86c2a7574e0ece0c70208cac7afe3efbb57f939d55b5ed6
MD5 4b2c33f47ea1ff89d1f92fe6a27d95c0
BLAKE2b-256 91287894fff80b50eeecc78dc94c1bca787cd31b6c4fdfcc3526b7fb2ebf7aa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 964d1b809bc2f92408d960cedbdd99fe5461afce15e30c6cef60672415fc4383
MD5 d81b098bcc665e758ac3c88da4ae8477
BLAKE2b-256 0e5fbc64420c3ee3507adf0a88d35264f5bd538064cba176766da4d08d1b8c5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a653449e094966f41c5381a1f11305fbb72018557d7b1b4b548cdd81677829ea
MD5 cf6f0094ec3ef15b2b1a9c343b36894c
BLAKE2b-256 c81f9e1cac942a5895c5f398de985d19331ae0601c59a37145f56536864f1bac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f8b70afafd6ca2983fa6a2071c558b7a75b21588fb869999250dec73c0b5bc3
MD5 e2a8b204dc699549c826fe83b43b577d
BLAKE2b-256 9c4fecff4221215e547daf714d8578c43bc2d0c570712f814eec409f02ef987f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bbe080d26cf8bb7cc95111e5a629737d55ca32f31b2c4d42eb9ebebc21764c99
MD5 e57d0d4342d2d784092d95bb3bd60447
BLAKE2b-256 4e1d7350a8fc1f8e42be630c30c5aca2b9610058c046492231f1ad83c0bd605f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8cea106350236f314663fc7125d3e4472a0c328c5978e19ea4a4c985c67baa21
MD5 5b763978f7c5c65e28d47a3d36f953b4
BLAKE2b-256 0ff5db9749589ddc7b890437d40bd515e9cd61e6c529ad9c42ae036e9e4499c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 80ba4b04bf03e634c99ab0d482d4d0c875291a0b899e07bc57d50b70cef1c051
MD5 6fcff2f1d3f9c73f73538fbf120896e7
BLAKE2b-256 bb6b284378ff415a8e312669241695cdee359fd66ea046915adfcd98d44c882d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc3178aade5dabca12cd62294f171d3ce931a8e1fed1ba6d0f03893e77e662f3
MD5 e573a52448f341f414a3d943181743ff
BLAKE2b-256 261af3979de83a62344b1e9fd246908d3879a85b830b6c70ed3f056e2c411db9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 521cbceee07a45f14cea7185fd9276d33fe691af2a8609a701d4dcb6b1d0499d
MD5 0b8278a6b8cab4e63304f560eb097e40
BLAKE2b-256 5aac32c3c852dc98ff077bc7e6caafed6bc0bc65c54407a80df77405be99ec40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d57baf1ec9b8df0ef42f6a274032ed8e36dbf02e39b8393e9ecbf25607fc4316
MD5 c1fe6fcb558940a10cd782ed2546d506
BLAKE2b-256 bd14d4ffbef12337d30fbed62cd7a31d7561b2713849dc99a08525e82050c207

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc12-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6b6dc0ad59bcde12e9a1f33a290d99e7d17cb5be07848980493c8568374004b1
MD5 d2984855ed081bc7b499c08186f023a9
BLAKE2b-256 143a693ec1fdc2bc92f80d14f42dcf03f7d9c39f4baba2b9708143e69dda2d02

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