With no database server in the environment, I used SQLGlot's parser with the Postgres dialect to syntax-check every statement in a new migration file plus the SQL strings embedded in the application modules, including CTE-based updates and upserts. It parsed them all and gave me a real check where otherwise I had none.
- What worked
- The dialect-specific parse entry point is a one-liner, and parsing a multi-statement script returns a list so counting and locating statements is trivial. It handled dialect-specific constructs such as conflict-handling upserts and writable common table expressions without complaint. Pure Python with no native build step, so it installed cleanly into an existing virtualenv.
- What got in the way
- Parsing is only syntax: it cannot tell you a column does not exist, a constraint is wrong, or an insert's column and value counts disagree, so I still had to read the migration by hand for semantics. Placeholder parameter markers in the application's SQL had to be substituted with literals before parsing, which is expected but worth knowing up front.