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

Uploaded PyPymanylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.12+ x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyturso-0.6.0rc6.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.0rc6.tar.gz
Algorithm Hash digest
SHA256 82e7e401d04b9972d513d27326b056693efaa4cbdd41b162e0ab231e62069557
MD5 9f773e21da666aa4bac905b5947f3de4
BLAKE2b-256 e8bf3d1e2f095e862ddb2e9801e4663248718d9ab25b108f3757bf8e2a84c3ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 13d35e52f42ee847e05cab6a1c17c45a2676d56a297383f1b8408375cc044edf
MD5 35f0eaaf3c13908a507e92427df064a9
BLAKE2b-256 4929af367635a0a7b8c27c4015bedb754c82308a9c7090f11ea9a5510bb4e213

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b157dc9e5eac5edce542f9135d67ff892e67442cb7739b283641178814cd072f
MD5 e53f4344a8bef98e02aeb466c3414251
BLAKE2b-256 00efdb1484cc147d8dcfc04e93c814ece8a40d0fdc265b853d543b1fe6eb31c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 440f48c0befb35f3cbb2cbb0f0c74dacc59043a65eda9265f6edb01fca6c588b
MD5 ddce6479e3edfbcae0b617a8861c71ee
BLAKE2b-256 1d2c513e230d6794f39a7133bf4bb8022329e87d9f1222a6a69f0428944870b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ad66dbd3f459b498e97396b71dc0678c8c1bc0640afa9c2a586fd8ff1c10fcdb
MD5 aba7aa014d52913d1e4a883d5e3f824e
BLAKE2b-256 5a4512f40b79df0dfb154dc1b54780ccb7470e41073839cedbe1ff492eb06b34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2429a7029345ef32559497e13579e54a1e951b3ab0545607afb83eb0953c7c2e
MD5 44432abb1a40acd6a34a6c1bfc076b9e
BLAKE2b-256 8a97a557c6a9fe5e283173887ee2a9d8f887de4271302b18b08a2a65a6ed2da6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ec0b7efc60047d5b71ca922a28e116e598996d44fd0f0048221509d6f6981268
MD5 62630a8dcda8f2b9c0825641f57f476b
BLAKE2b-256 1ffd79b243d72bf69e5f567f0baac6f01deceb18d25d84426e94b0d3d1428542

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 709a40bc643f0d3f172a02a474dda05bd152af734529b1e1bf87477c71813d38
MD5 00f471376008ebda1f564edae18cedb1
BLAKE2b-256 d440744f0d6fc3a9edf7717ad9ee1f9306ad337d01e2f6cfd146fd53ab861eb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5f9c81a418da4ce6d8c461cfb0949150bedb3c4339092153206357255519d3e5
MD5 e066efc148d0c15f35f36354cacfc663
BLAKE2b-256 ecde2688315b92cfd11010f56de23b169b02d18f9d5772650b11eee99acc65c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d947ca4a31dfe7e370f0f56462d57a2cc0b73bf67bd356d2fdec12a72f1feb0f
MD5 733dd4473f70764342efc82b6874a0ea
BLAKE2b-256 132f8575424ab4c6340828af4f97d01aa80ccdf83ff94a5d3fa1a4580e6900f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a10edc00f9cdbaec09d052a5bd3b73f0a41b81e2e8d5cbce64f71e3646959593
MD5 a54f98f173635c2e1fee351dd48f2cbd
BLAKE2b-256 d4f18e9a1b4051dc543002bf9d887e0354c7ad127de1850e7047098b1c6e73c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ad2c004528dfd18df8ee1a367df39a557a3a91b31ffc0d0b91a31dee67c00375
MD5 32a0e7f0d284a2973c9ea3d35890c11e
BLAKE2b-256 29fd379bd8c6c810ed87808c330fc4e852170aac106de4dbf501aaa6f54b6b9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1e8a328e6f4cd5fed646cdf89203a07c3ed867cf3db24b3a06d80686d2395ede
MD5 65da268b5b694feca12be3ce4cc8deb0
BLAKE2b-256 16c3b0ee57cf811647bc9cd0e79aea4cdfa65e7fa14d3e2bf800c26675cd4822

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ef1df9fde8eb22be85e012cc3f9c4608a865107b4d8f0b2e23f569c8711f34a3
MD5 41012a4a85e0e04557d98d0971dcdfe3
BLAKE2b-256 a558fcf86e07d65bd1284bf2a82f3d2614a33d83c1487772afb9c7d822c154c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1595ea3ef8c633bb7406c1fcbf8a39db16338872c1107239aa4515a5a57d31cb
MD5 940268d1bb88feffd1258f33f38bc602
BLAKE2b-256 8b658ddfc10a641447aa843ffe2271e08650cd649b0f15d7af24af7c97f046c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9578d84f24a297a7435e9984400de450dcc4e1b52946e67b296db92e0fd3ce3
MD5 535ae5b5fd04160d417edb54bc3da280
BLAKE2b-256 89938692eacc55cedc7fd380d142594da8d7769acc2a070a542464604f111901

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 430447648076aaba19c3e4fcbb01c0178368be9bccd2b6fd7989e1df556d6122
MD5 9b72f634be4ac6700fcac280efc9f2c0
BLAKE2b-256 39c36bfbf87aaed6f9ba4dd4fcdb9173c319b2e0c341ca3550f1c57b4743b16d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be9973921b71464b9b5320ec55b170896eaa259943749dadf86f0a04d23c2d80
MD5 5e3deb29e81cfe41806b349abc990de9
BLAKE2b-256 5e2910fdeb30d75550f5a8f3e02d926384d64d313cfcc0efc4e420051461321a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 be9d2e1a6c0d29d1f88af61dace57e28640a82c5d7e3dccba44ea6eb691d9143
MD5 4292efef79b8db4e7c2b492ffdf71620
BLAKE2b-256 f6c4b3b220535f44f6225789e8226021a7d550628b9f4b93a997ab136a06a470

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 107276c9b653fa0f3ed96a247faabf7f5d068e10463f672676954b674ee9c6b4
MD5 bbe8983f32c2cb479531b6d4fb90f9d8
BLAKE2b-256 54f048310b8945bd317c035d02c7e0ce33b0abfa9c6a1d7573697d96a468d214

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4323f7e3eb539d03e282b3b97e75ebbc89627bea4fbf3681b869a92e39fa7f9a
MD5 6aec0b3ab63cc72ef46a38e84d1c7198
BLAKE2b-256 52c9a553b1f9df4fc8ea80bef35f02130b72d27ca2560fa97d2ab0bca840112e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9354a9c5f6e9bf0696a83a82622b3e22a2413836f5b9464b40edd30489d3509
MD5 e9bcb283e5019c6b75e3785908a77f64
BLAKE2b-256 8c80a7c398b075c5181293bbd4c77de6bb421325663a7ae7cdce23b1c0bf6f93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyturso-0.6.0rc6-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 17ffad3ce89a5819716f9596d0010dbfc907576780c2077326dc1b6cb0dc721f
MD5 6b6e623cf58f89f206ff4ed5fb0c22fd
BLAKE2b-256 e6f6a8b7b2b2c5d2386eb8392cc2688062e70ceeabb813ba02ab872c431f6b86

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