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.0rc7.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.0rc7-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.0rc7-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.5 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pyturso-0.6.0rc7-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.0rc7-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.12+ x86-64

pyturso-0.6.0rc7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

pyturso-0.6.0rc7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyturso-0.6.0rc7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

pyturso-0.6.0rc7-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.0rc7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

pyturso-0.6.0rc7-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.0rc7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyturso-0.6.0rc7.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.0rc7.tar.gz
Algorithm Hash digest
SHA256 72c801adb4f3bd9fdb41bf0582aa78f85a4cebe7c8468906a81fc73e69bf8c53
MD5 1b120d8dd382898bb4d8620cfcc4bf70
BLAKE2b-256 f9b82e905339dddf27a0192f0edb49708fd6ec11d0c2045876d70877e2c562b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bb44e7cd83370ddcc29e0c11632e2428ab51ae75855da6cb9550e93c61ba18f
MD5 78504e870c4a335a341802604de647e4
BLAKE2b-256 fbf0b05c7efe27815462510fa21c61c6416ec194eb0af9df2ef41e0510af4a7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aaaa82460ba1ab9391c18b87a63ea59e036c182cfd70ecff6de13a5f895cb155
MD5 078e364874e3b992195991e620b7f3f1
BLAKE2b-256 286f5e2cbf222b7e4aaa2031e0cb48cf993dc166c192d7aa751b387c0897a697

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dad2e327fc2416d2148735e0cbee273e0d4a74b089c4e187c5ecbae8b18f9c86
MD5 397d1710751eb58232dbcdff27d0926c
BLAKE2b-256 fd7ade737724d08afafa761c718aa4224e056467e005be4845be691cae473c41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b09bff3e76c67e58d0377e1113824743b71fa2d5845950b31db19a728b379024
MD5 153401252b9787ba813ec34b8d22c0ce
BLAKE2b-256 8a2faadcf4ac80204ad397a59daad9366cc1c8475b3c1da584d9f7cfa3d2e927

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5dd7397fabdb84d7fd4cd41f64a6f81b62430d4376a5212440e66a4247be33a
MD5 e112d72f2faa043f4b02c2d690783bbe
BLAKE2b-256 0be440e16374f49c4fa553bb45a06c911b8cede6d0c34bf675a1b67d3d5f650f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 798fb6ed3659aec1be07fa900c6c8ec370e4d99ec5db4531f18cdfec65b2a331
MD5 bd0167203efd191926c6402614e07c2f
BLAKE2b-256 0940d87f02265f9242b1df41afc6fc0ff589a53a605603f9ba094fc1f879df5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 296fee7625f9937b4e627942f5207552dd5077dd9a97fe7a85432b11dbd6c684
MD5 4185caad60a1dafdfecda4f65d5e519b
BLAKE2b-256 f05a4428b4624d8ec6970b088f41d258f8ab5494ac18a5e3c3d0d7d489d408bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f14cb406d422f1f5c24a27b6b3de697efaa9c324c8d79fe4c9d1793fefd279e5
MD5 f1246631f2ec23fafbb9b69a13e7b0cf
BLAKE2b-256 6c0b03ed8768eef6bab03eff588187fda06cb30e641a830c6ac927a2321176e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a8a98ac191902758e028eed231277f9b47d7ebfc828eab65dbd32c45846290e
MD5 642d26d40c7802803589929a5a9c16e4
BLAKE2b-256 b0a6af76d81eba148b3f5ac1f7afd4285fa5109795fad43175e0c30475384dcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3c355e5a5156abad84743113fb401753f22d890014d2ab5a0686f92850ee8721
MD5 8dbc178900fb5a0214ef7a8dc9a37938
BLAKE2b-256 57ab2db20340fe1ac7ee8d8dd48619cbf11a66f75b13496913e43265a8ddbdd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 23a0094b1fbc2269793a71794d850a25e34e9e01805f4a36d9aff931f7655e97
MD5 c3284ff48fc1d26a0d8373c88372cbd8
BLAKE2b-256 c3babaa35387d36c982fac76762c355e1a3e9236f9d24f7e9b21de4a94df15c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 774926b37d49b95109192d999caa8428977808e1ad6ec998fbbc47662cd1411f
MD5 bf96f0ba3372c5a9fb22fc99d39eef78
BLAKE2b-256 4c4627294af08019aa7435ea20962fbbfa3cd7f7fefa87e8042425305172c883

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d201f428350ce0bf056ffd1e1a91faaa78945829e9a44774a1abea5efead5c6b
MD5 242ea92918805f5ac699e6bf714df8ef
BLAKE2b-256 56ccc3b13301f5e9e3f5e61275b8c2ce70fcdc614dd6aebeb9ced11303c8bec5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e8a1f077544b60d1efb56005ee33eaf33c5490a587ddd92dc94b499232b15518
MD5 f52dce930bfc6f63a0bc16d085c7d139
BLAKE2b-256 ad918ebefd384cef9dfebc08cf92307149d6eb5aac462fb3e59a0922be8ab768

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1cd229b5096492fd56dafde372acb5e6884834aeee55a52678bdbc35c634909c
MD5 4a11e07de8cc3bb02112cd5d61bc9e40
BLAKE2b-256 b99bcb64e9b93d061fb3a76f924a653731d5ebdcc2006d04f1d33eced5273045

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bcb8e070b330615d8212c7c8d14ce7664c38d5265fce87c8a8612ad6b9d01029
MD5 8ade9654323503f418a9501cbc10b259
BLAKE2b-256 70197e9bb87cdc1da12984da32751b8daee12cee41a89f6ceb837094060fba6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c728c2baf6b5fcf7c3d5248eb29b6a942726e09822dd3505a3544e4579d82611
MD5 8ba9ca58445ae653e27ad6b60465d43b
BLAKE2b-256 49575f80d77b80b61f7945381f42c4c9b1c02f829ed3e420d3a575927d6ccb31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9b149edbc0e91b4fbbfeb3cfe09d624af42cca3769e04889a4d177281d410958
MD5 d8cb72f45be6c98280084abb5f3c8662
BLAKE2b-256 9766f4172472f88591b94bc1baf5bcc356987b8b151d321d22a892a52f362d83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a8a8618f4e855e22ce49c73b646504ed5a308b0c5ae7ba354b29dda70ab7eaed
MD5 1441983797b8ac025ec446221b20f57d
BLAKE2b-256 3509b0f843145a2b955180e2fd637d1905cc5ef5946cb6bea08c650d501dfd71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 caeddc5a798442c4e21c58e2e801edb96b4f0cbe65ae7ec91aeb574b0c1774dc
MD5 99760feaab3a4cf4c55eba8223ffbaec
BLAKE2b-256 7636cd88efcd26392181983f925a4202b5d7a1f5bd6681138f102247e2551eb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4645a9df9e2ef8cc7969ee53e98618c361832106ec484eb6c9a26c4cec018b76
MD5 effcf12ac337b29cac28a890fa497ce7
BLAKE2b-256 de9d8f570440de577c0240ad39b36a442cd528409e75d8efc7a21cc84dd07fe9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc7-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0a9e49875226fa9e85602fabc626d044e97dd9cbe70cfd44cc365ab24fc2edc4
MD5 1f0dae743b10c0a519043e878ae3d0af
BLAKE2b-256 5386b756fdb507465567febc639d0205be3f5645184954d1875aa455c73a810f

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