SQLite async connection pool for high-performance

https://news.ycombinator.com/rss Hits: 18
Summary

aiosqlitepool aiosqlitepool is a high-performance connection pool for asyncio SQLite applications. By managing a pool of reusable database connections, it eliminates connection overhead and delivers significant performance gains. Important: aiosqlitepool is not a SQLite database driver. It's a performance-boosting layer that works with an asyncio driver like aiosqlite, not as a replacement for it. aiosqlitepool in three points: Eliminates connection overhead : It avoids repeated database connection setup (syscalls, memory allocation) and teardown (syscalls, deallocation) by reusing long-lived connections. : It avoids repeated database connection setup (syscalls, memory allocation) and teardown (syscalls, deallocation) by reusing long-lived connections. Faster queries via "hot" cache : Long-lived connections keep SQLite's in-memory page cache "hot." This serves frequently requested data directly from memory, speeding up repetitive queries and reducing I/O operations. : Long-lived connections keep SQLite's in-memory page cache "hot." This serves frequently requested data directly from memory, speeding up repetitive queries and reducing I/O operations. Maximizes concurrent throughput: Allows your application to process significantly more database queries per second under heavy load. Table of contents Installation aiosqlitepool requires the aiosqlite driver to be installed as a peer dependency. Install with your preferred package manager: pip pip install aiosqlite aiosqlitepool uv uv add aiosqlite aiosqlitepool Poetry poetry add aiosqlite aiosqlitepool Usage Basic usage You must provide a connection_factory - an async function that creates and returns a database connection: import asyncio import aiosqlite from aiosqlitepool import SQLiteConnectionPool async def connection_factory (): return await aiosqlite . connect ( "basic.db" ) async def main (): pool = SQLiteConnectionPool ( connection_factory ) async with pool . connection () as conn : await conn . execute ( "CREAT...

First seen: 2025-07-14 21:00

Last seen: 2025-07-15 14:03