aiosqlite

Async/await-friendly wrapper around Python's built-in sqlite3 module for asyncio applications.

Library
PyPI
v0.22.1
1,583 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
39 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 85
Code Quality 88
Innovation 62
Learning Curve 70

aiosqlite provides an asyncio-compatible interface to SQLite databases by wrapping the standard library’s sqlite3 module. It replicates sqlite3’s connection and cursor APIs almost exactly, but every method becomes an async coroutine, so applications built on asyncio can talk to SQLite without blocking the event loop.

Under the hood, aiosqlite runs a single dedicated worker thread per connection and funnels every query through a shared queue, guaranteeing that SQLite calls — which are not safe to use across arbitrary threads — happen serially on one thread while the asyncio event loop stays free to do other work. Context managers handle closing connections and cursors automatically, and the library also exposes convenience helpers like execute_fetchall and an async iterdump for common patterns.

What You Get

  • Async equivalents of sqlite3’s Connection and Cursor objects, with the same method names and semantics
  • A dedicated worker thread per connection that serializes SQLite calls off the event loop
  • Async context managers for connections and cursors that close resources automatically
  • Convenience helpers like execute_fetchall, execute_insert, and an async iterdump for streaming SQL dumps
  • A fully typed API (py.typed marker) for editor and mypy support

Common Use Cases

  • Adding SQLite persistence to an asyncio web service (e.g. FastAPI or aiohttp) without blocking request handling
  • Local caching or job-queue storage for async workers that need durable state
  • Prototyping and testing async data-access layers before moving to a networked database
  • Desktop, bot, or CLI asyncio apps (e.g. Textual TUIs, Discord bots) that need embedded, file-based storage

Under The Hood

Architecture

aiosqlite is a small, cleanly layered module: core.py defines the Connection proxy, which owns a single background thread and a queue-based transaction pipeline; every sqlite3 call is wrapped as a partial and pushed onto that queue, executed serially on the worker thread, with results or exceptions marshalled back to the asyncio event loop through call_soon_threadsafe. cursor.py’s Cursor class is a thin proxy over sqlite3’s cursor that reuses the same execution plumbing and adds chunked async iteration for streaming query results. context.py supplies a decorator that wraps coroutine-returning methods in a dual-purpose object implementing both Coroutine and an async context manager, so a single method like execute() can be used as either a plain await or an async with block. This design cleanly isolates the one hard constraint — sqlite3 objects must be used from a single thread — behind an async-friendly interface, and the worker thread plus its queue is the abstraction everything else hinges on.

Tech Stack

aiosqlite targets Python 3.9+ and has zero runtime dependencies beyond the standard library — the entire implementation is three small modules. Packaging uses flit_core as the build backend, docs are built with Sphinx and published to Read the Docs, and the dev toolchain (declared as optional dependencies) includes black, usort/ufmt for formatting, mypy for static typing, and flake8 with flake8-bugbear for linting. Continuous integration uses uv to install dependencies and runs the test/lint/build/publish pipeline across multiple Python versions on macOS, Ubuntu, and Windows, publishing to PyPI via trusted publishing on tagged releases.

Code Quality

Tests live in a substantial smoke-test module built on the standard library’s IsolatedAsyncioTestCase rather than pytest, covering connection lifecycle, cursor iteration, error propagation, backup, iterdump, and authorizer callbacks, alongside a dedicated performance-test module; coverage configuration enforces a minimum threshold. Static analysis is enforced through mypy and flake8 with flake8-bugbear, both run in CI alongside the test matrix, and the package ships a py.typed marker so downstream consumers get type-checked signatures. Error handling favors letting sqlite3’s own exception types propagate unchanged — they’re re-exported directly from sqlite3 rather than wrapped — and naming conventions mirror the stdlib API closely for familiarity.

API Design aiosqlite’s core design goal is API parity with the synchronous sqlite3 module — Connection and Cursor expose the same method names with await added, so migrating existing sqlite3 code is largely mechanical. The dual coroutine/context-manager return type is the one genuinely distinctive ergonomic choice, letting the same call site work as a plain await or an async with block depending on whether the caller needs the cursor for iteration. Beyond that, aiosqlite deliberately stays a thin, familiar wrapper rather than introducing new query concepts or abstractions, which suits its scope but doesn’t set it apart technically from a straightforward thread-executor wrapper around sqlite3.

Used by 15 apps in this directory

Rust
48%
MIT

Meetily

AI Assistants · Productivity

32,103

Privacy-first AI meeting assistant that transcribes and summarizes your meetings entirely on your local machine — no cloud, no data leakage.

View details
87
Repo Health
72
Technical
67
Dependency
Built with
Rust 48%
TypeScript 29%
Updated 6 days ago
Python
38%
Other

Open WebUI

AI Agents · AI Assistants

156,607

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
92
Repo Health
75
Technical
66
Dependency
Built with
Python 38%
Svelte 35%
JavaScript 19%
Updated 5 days ago
Python
100%
Other

OpenBB

Analytics · Databases · Invoicing Finance

74,601

The AI Workspace for Finance: Connect Data, Run AI Agents, Build Analytics

View details
80
Repo Health
80
Technical
65
Dependency
Built with
Python 100%
Updated 1 weeks ago
Python
68%
Apache 2.0

otari

AI Development · Developer Tools

733

A self-hosted, OpenAI-compatible LLM gateway that puts one endpoint in front of 40+ providers, with virtual API keys, per-user budgets enforced before spend, and full usage tracking.

View details
82
Repo Health
88
Technical
74
Dependency
Built with
Python 68%
TypeScript 31%
Updated 6 days ago
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,976

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated 5 days ago
Python
79%
AGPL 3.0

Skyvern

AI Agents · Automation

23,257

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 79%
TypeScript 19%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers