aiosql
Simple SQL in Python
Decision gist · record as of 2026-08-14
Yes. aiosql is actively maintained, has no runtime dependencies, requires only Python >=3.10, and carries no known vulnerabilities. It's worth installing if you want to keep SQL in files and call it from Python without an ORM, and you're comfortable writing SQL directly. Skip it if you need an ORM or prefer SQL-like syntax in Python.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python >=3.10 and a compatible database driver (sqlite3, psycopg, asyncpg, etc.) installed separately.
- Low friction install with no runtime dependencies.
- Active maintenance with last commit 2026-07-10 and 1409 repository stars.
License · maintenance · safety
BSD-2-Clause (permissive) — BSD-2-Clause permissive license allows commercial and private use with minimal restrictions.
last release 2026-01-04 (222 days) · last repo commit 2026-07-10 · 1,409 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 162,590 downloads/mo, #10,595 on PyPI
Alternatives
Verify before relying
pip install aiosql
import aiosql
import sqlite3
queries = aiosql.from_path("greetings.sql", "sqlite3")
with sqlite3.connect("greetings.db") as conn:
user = queries.get_user_by_username(conn, username="willvaughn")- Whether all listed database drivers work equally well or if some have known limitations beyond what the description states
- Performance characteristics when loading and executing many queries from a single SQL file
What it is and what it does
aiosql lets you organize SQL queries in separate .sql files and load them into Python as callable methods, rather than embedding SQL as strings in your code. This approach keeps your SQL reusable—you can run the same queries in psql or other database tools without modification—while maintaining clean separation between SQL and Python logic.
The package works with both synchronous PEP 249 drivers (sqlite3, psycopg2, PyMySQL, etc.) and asyncio-based drivers (aiosqlite, asyncpg, asyncmy, etc.). You write parametric SQL with named parameters, load the file via aiosql.from_path(), and call queries by name, passing a connection object and any required parameters. It's a lightweight alternative to ORMs when you want to write and maintain SQL directly.
Use it for
- Organize complex SQL queries in version-controlled .sql files for a Python application using SQLite or PostgreSQL
- Run the same parameterized SQL queries from both Python code and command-line tools like psql without duplication
- Build async applications that execute multiple SQL queries concurrently using aiosqlite or asyncpg
- Maintain SQL code separately from Python when you prefer hand-written queries over ORM-generated SQL
- Support multiple database backends (SQLite, PostgreSQL, MySQL, DuckDB) with a single query file and driver parameter
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
aiosql is actively maintained, has no runtime dependencies, requires only Python >=3.10, and carries no known vulnerabilities. It's worth installing if you want to keep SQL in files and call it from Python without an ORM, and you're comfortable writing SQL directly. Skip it if you need an ORM or prefer SQL-like syntax in Python.
Install
aiosql on PyPI
Before you install
Low friction install with no runtime dependencies. Active maintenance with last commit 2026-07-10 and 1409 repository stars. Requires Python >=3.10.
Requires Python >=3.10 and a compatible database driver (sqlite3, psycopg, asyncpg, etc.) installed separately.
License in practice
BSD-2-Clause permissive license allows commercial and private use with minimal restrictions.
Quickstart
pip install aiosql
import aiosql
import sqlite3
queries = aiosql.from_path("greetings.sql", "sqlite3")
with sqlite3.connect("greetings.db") as conn:
user = queries.get_user_by_username(conn, username="willvaughn")
Verify before relying
- Whether all listed database drivers work equally well or if some have known limitations beyond what the description states
- Performance characteristics when loading and executing many queries from a single SQL file
Package facts
| License | BSD-2-Clause permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 222 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 162,590 / month, #10,595 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: SQLTopic :: DatabaseTopic :: Software Development :: Libraries :: Python Modules |
Evidence: aiosql-15.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “SQL queries from files”
- aiosqlLoad SQL queries from files and call them as Python methods,…
- shillelaghShillelagh lets you query APIs, files, spreadsheets, and in-memory…
- dirsqlWatches a local directory, indexes structured files into an in-memory…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also databases · aiosqlite · asyncmy · aiomysql · apsw · apswutils · pysqlsync · asyncmy2 · hopsworks-aiomysql · duckdb