PyPika
lastmod 2026-11-10created 2022-08-262 edits
PyPika is a query builder library that assembles SQL queries from Python code. Unlike an ORM, it does not map tables to classes; instead it builds SQL strings by chaining methods, as in Query.from_(table).select(...).where(...), and can express most SQL features, including joins, subqueries, aggregation, and window functions. It does not handle database connections, so you run the generated SQL with whatever driver you like, and it handles syntax differences between dialects such as MySQL, PostgreSQL, and SQLite.
SQL query builder that exposes the full richness of the SQL