Registry / database / anysqlite

anysqlite

JSON →
library0.0.5pypypi✓ verified 49d ago

Anysqlite provides an async/await interface to the standard `sqlite3` library, supporting both Trio and Asyncio backends using the `Anyio` library. It is currently at version 0.0.5 and has an irregular or slow release cadence, with the last update in October 2023.

databasehttp-networking
pip install anysqlite
Install & Compatibility
Where this runs
tested against v0.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.298s · 20.1MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.8s · import 0.254s · 21MB
18MB installed
● package 18MB
Code
Verified usage

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

anysqlite
import anysqlite
The primary library module providing the `connect` function and other database operations.

This quickstart demonstrates how to establish an asynchronous connection to an SQLite database (in-memory in this example), execute SQL commands, insert data, and fetch results using `anysqlite`.

import asyncio import anysqlite async def main(): # Connect to an in-memory database for quick testing # Or use a file path like "my_database.db" conn = await anysqlite.connect(":memory:") try: # Execute a simple query cursor = await conn.execute("SELECT DATETIME('now')") response = await cursor.fetchone() print(f"Current datetime from SQLite: {response[0]}") # Create a table and insert data await conn.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)") await conn.execute("INSERT INTO users (name) VALUES (?)", ("Alice",)) await conn.execute("INSERT INTO users (name) VALUES (?)", ("Bob",)) await conn.commit() # Fetch data cursor = await conn.execute("SELECT id, name FROM users") users = await cursor.fetchall() print("Users in database:") for user_id, user_name in users: print(f" ID: {user_id}, Name: {user_name}") finally: # Ensure the connection is closed await conn.close() if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
gotchaThe project is at a low version (0.0.5) and has not seen recent significant development or releases (last release Oct 2023, last commit 3 years ago). This may imply a slower response to issues, potential for breaking changes in future minor releases, or unaddressed bugs.
fix
Thoroughly test `anysqlite` in your specific use case. Consider contributing to the project or reviewing alternative async SQLite wrappers like `aiosqlite` if active development and a larger community are critical for your application.
affects: <0.0.5
gotchaAnysqlite relies on `anyio` for its asynchronous backend. Ensure `anyio` is correctly installed and compatible with your chosen event loop (asyncio or trio) to prevent runtime errors related to asynchronous execution.
fix
Verify your `anyio` installation and its configuration within your async environment. Consult `anyio` documentation for specific backend setup if issues arise.
affects: All versions
gotchaAs with any `sqlite3` wrapper, be mindful of potential blocking operations if complex or long-running queries are executed, especially without proper offloading. While `anysqlite` provides an async interface, the underlying `sqlite3` can still block the event loop if not used carefully.
fix
For very complex or large database operations, consider using `run_sync_in_worker_thread` from `anyio` or similar mechanisms to explicitly offload blocking work to a separate thread, preventing the main event loop from stalling.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'anysqlite'
The 'anysqlite' package is not installed in the Python environment.
fix
Install the package using 'pip install anysqlite'.
AttributeError: 'NoneType' object has no attribute 'sqlite_db'
Attempting to access 'sqlite_db' on a 'NoneType' object, possibly due to an uninitialized or improperly configured database connection.
fix
Ensure the database connection is properly initialized before accessing 'sqlite_db'.
AttributeError: can't set attribute
Attempting to modify an immutable property or misconfigured relationship in a SQLAlchemy model.
fix
Verify column properties and avoid modifying immutable attributes directly.
AttributeError: 'ConexionDB' object has no attribute 'execute'
The 'ConexionDB' class lacks an 'execute' method, possibly due to incorrect implementation or missing inheritance.
fix
Implement the 'execute' method in the 'ConexionDB' class or ensure it inherits from a class that provides this method.
AttributeError: type object 'Cliente' has no attribute 'query'
The 'Cliente' class is missing the 'query' attribute, likely due to improper setup with SQLAlchemy.
fix
Ensure the 'Cliente' class is correctly defined as a SQLAlchemy model and the database session is properly configured.
Upgrade
Version history
0.0.5latest on PyPI
Audit
Dependencies
anyiorequiredProvides the async/await backend support (asyncio or trio) required for anysqlite's asynchronous operations. Version >=3.4.0 is required.
Agent activity
27 hits · last 30 days
node
4
claudebot
4
seranking-bot
4
ahrefsbot
3
amazonbot
1
bytedance
1
Resources