scythe
A SQL toolchain that compiles annotated .sql files into type-safe database access code for ten languages and ten databases, with linting, security auditing and pre-commit hooks.
Scythe reads .sql files statically and compiles them into database access code: row types, query functions and type mappings that stay in sync with the schema. Because it needs no database connection or network access, it can run inside a pre-commit hook.
Type inference follows nullability through joins, CTEs, window functions and aggregates, and maps enums, arrays and JSON to language-native types. It ships 59 built-in rules: lint rules such as UPDATE without WHERE or SELECT *, and audit rules covering dangerous functions, GRANT to PUBLIC and migration-safety issues such as locking ALTER statements. scythe check verifies that committed generated code still matches the SQL it came from, and can check for schema drift against a live PostgreSQL catalog.
It targets one database engine per configuration block rather than abstracting across engines like an ORM, and is written in Rust under the MIT license.