Registry / database / libsql-client

libsql-client

JSON →
library0.3.1pypypi✓ verified 84d ago

Python SDK for libSQL, a fork of SQLite designed for modern applications. Supports local and remote database connections via HTTP or WebSockets. Current version 0.3.1, actively maintained.

pip install libsql-client
INSTALL
IMPORT
SIG · LIBSQL-CLIENT
L
libsql-client
databasepythonv0.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

create_client
from libsql_client import create_client
import libsql_client
Direct import of libsql_client will not expose create_client; use explicit import.
Client
from libsql_client import Client

Create a client and run a basic query.

import asyncio from libsql_client import create_client async def main(): url = os.environ.get('LIBSQL_URL', 'file://local.db') auth_token = os.environ.get('LIBSQL_AUTH_TOKEN', '') client = create_client(url, auth_token=auth_token) rs = await client.execute("SELECT 1") print(rs.rows) await client.close() asyncio.run(main())
Debug
Known issues
breakingv0.2.0 changed the client API from synchronous to asynchronous. Old code using synchronous calls will break.
fix
Use async/await with all execute calls.
affects: >=0.2.0
gotchaThe client must be explicitly closed with await client.close() to release resources. Neglecting this may cause connection leaks.
fix
Use try/finally or async context manager (not yet available, so manual close).
affects: all
gotchaWhen connecting to a remote libSQL server, the client uses WebSockets by default. Ensure the server supports WebSocket connections; otherwise, use HTTP mode by setting scheme='https'.
fix
Pass scheme='https' to create_client() for HTTP-only servers.
affects: all
deprecatedThe 'db_url' parameter was renamed to 'url' in v0.3.0. Passing 'db_url' still works but is deprecated.
fix
Use url= instead of db_url=.
affects: >=0.3.0
Errors
Common errors & fixes
AttributeError: module 'libsql_client' has no attribute 'create_client'
Incorrect import (import libsql_client instead of from libsql_client import create_client).
fix
Use: from libsql_client import create_client
RuntimeError: This event loop is already running
Trying to run asyncio.run() inside a Jupyter notebook or an environment with an already running event loop.
fix
Use await client.execute(...) directly in a notebook cell if using IPython >= 7.0, or nest with asyncio.run() only at top level.
libsql_client.exceptions.ConnectionError: Connection refused
The remote libSQL server is not reachable or the URL scheme is wrong (e.g., http instead of https).
fix
Ensure the server is running and use the correct URL (e.g., https://your-server.com).
Upgrade
Version history
0.3.1latest on PyPI · released May 3, 2024
Audit
Dependencies
protobufoptionalRequired for gRPC-based connections
Agent activity
8 hits · last 30 days
node
6
Resources
libsql-client — pip install libsql-client · libregistry