{"id":2862,"library":"anysqlite","title":"Anysqlite","description":"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.","status":"active","version":"0.0.5","language":"en","source_language":"en","source_url":"https://github.com/karosis88/anysqlite","tags":["sqlite","async","database","anyio","trio","asyncio"],"install":[{"cmd":"pip install anysqlite","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Provides the async/await backend support (asyncio or trio) required for anysqlite's asynchronous operations. Version >=3.4.0 is required.","package":"anyio","optional":false}],"imports":[{"note":"The primary library module providing the `connect` function and other database operations.","symbol":"anysqlite","correct":"import anysqlite"}],"quickstart":{"code":"import asyncio\nimport anysqlite\n\nasync def main():\n    # Connect to an in-memory database for quick testing\n    # Or use a file path like \"my_database.db\"\n    conn = await anysqlite.connect(\":memory:\")\n\n    try:\n        # Execute a simple query\n        cursor = await conn.execute(\"SELECT DATETIME('now')\")\n        response = await cursor.fetchone()\n        print(f\"Current datetime from SQLite: {response[0]}\")\n\n        # Create a table and insert data\n        await conn.execute(\"CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)\")\n        await conn.execute(\"INSERT INTO users (name) VALUES (?)\", (\"Alice\",))\n        await conn.execute(\"INSERT INTO users (name) VALUES (?)\", (\"Bob\",))\n        await conn.commit()\n\n        # Fetch data\n        cursor = await conn.execute(\"SELECT id, name FROM users\")\n        users = await cursor.fetchall()\n        print(\"Users in database:\")\n        for user_id, user_name in users:\n            print(f\"  ID: {user_id}, Name: {user_name}\")\n\n    finally:\n        # Ensure the connection is closed\n        await conn.close()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"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`."},"warnings":[{"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.","message":"The 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.","severity":"gotcha","affected_versions":"<0.0.5"},{"fix":"Verify your `anyio` installation and its configuration within your async environment. Consult `anyio` documentation for specific backend setup if issues arise.","message":"Anysqlite 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"As 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}