Python SDK for Turso, a distributed SQLite database built on libSQL. Provides a dbapi2-compatible interface for connecting to local SQLite files, libSQL servers, and Turso hosted databases. The package name on PyPI is libsql-experimental (not 'turso').
pip install libsql-experimentalVerified import paths — ran on the pinned version, not inferred.
Connect to a Turso database using an embedded replica pattern with local SQLite file and remote sync.
pip install libsql-experimental
Call conn.sync() after writes and before reads that need fresh remote data.
Always call conn.commit() after write operations, or use conn.executescript() which auto-commits.
Provide a valid local file path: libsql.connect('local.db', sync_url=url, auth_token=token)Remote only: libsql.connect(url, auth_token=token). Embedded replica: libsql.connect('local.db', sync_url=url, auth_token=token).Pin your version in production: libsql-experimental==0.0.49
Ensure `gcc` or a development package like `build-base` is installed in your `musl` environment. For Alpine Linux, run: `apk add build-base`.
Ensure you have the Rust toolchain (Rustup, Cargo) and C++ build tools (e.g., from Visual Studio Build Tools) installed. Consider using a Linux or macOS environment, or a Docker container for development, as Windows support can be challenging due to platform differences in build environments. Upgrading `libsql-experimental` to a newer version might also include fixes for these build issues.
Ensure that your code is run within an `asyncio` event loop. For example, wrap your connection and query logic in an `async` function and run it using `asyncio.run()`.
Install the package using pip: `pip install libsql-experimental`. If you are using virtual environments, ensure your environment is activated before installation and when running your script. Verify the Python interpreter being used (e.g., `which python` and `python -m pip install ...`).
Instead of passing `None` directly, explicitly pass an empty string `''` or a string representation of `NULL` if your schema allows it and the database interprets it correctly as a `NULL` value, or wait for a library update that implements this functionality.
No dependency data recorded yet.