Skip to content

SQLTy vs aiosql and PugSQL

aiosql and PugSQL turn named queries in .sql files into Python functions. Neither checks the SQL or types the rows. A misspelled column surfaces only when the query runs. SQLTy checks those files as they are: point queries at them and sqlty check reports problems before the code runs. Use them together.

Quick comparison

aiosql 16.2 / PugSQL 0.3 SQLTy 0.10
What it does Loads -- name: queries as functions Checks SQL against the schema
Types of loaded functions None (__annotations__ is empty) Row types inferred from the schema
Misspelled column OperationalError when the rows are fetched unknown-column, did you mean email, before it runs
Header formats aiosql -- name: get_user(email)^; PugSQL -- :name get_user :one Reads both (query-format = "auto")

Where SQLTy is stronger

  • Checks every query in the file, against the schema, in CI and the editor.

Where aiosql and PugSQL are stronger

  • They run the queries. SQLTy doesn't, so you need one of them, or a driver.

Which should you choose?

Both. Keep aiosql or PugSQL to load and run, and add [tool.sqlty] queries = ["queries/*.sql"].

What SQLTy is missing

  • Typed functions: the loaded functions stay untyped, because SQLTy writes no stubs for aiosql or PugSQL.

Common questions

Do my .sql files need to change?

No. query-format = "auto", the default, reads aiosql's -- name: and PugSQL's -- :name headers as they are.

Sources

  • aiosql 16.2, PugSQL 0.3.7 (PyPI), rerun on one schema with a misspelled column, sqlty 0.10.0 (2026-12-01)