sqlc turns SQL queries into typed code for your language. You write SQL, run the tool, then call generated interfaces from application code.
Overview
sqlc is a SQL compiler that generates type-safe code from SQL you maintain by hand. The workflow is to author queries in SQL, run sqlc to emit code with typed accessors, and integrate those generated calls in the rest of the application.
The generated layer is meant to remove handwritten boilerplate for query execution while keeping SQL as the source of truth. Multiple databases and languages are supported; additional languages can be added through plugins.
Downloads, documentation, and an online playground let you try queries interactively. Installable binaries are published for common desktop operating systems.
Recent releases have added capabilities such as local managed databases for development workflows. The tool is intended to catch query and typing issues earlier in development rather than only at runtime.
Key features
- SQL-authored queries as source input
- Generated type-safe query interfaces
- Plugin support for more languages
- CLI-driven code generation
- Documentation and interactive playground
- Desktop binaries for major OS targets
- Managed local database workflows
Use cases
- Typed data access without hand-written DAOs
- Keeping SQL explicit in the codebase
- PostgreSQL or MySQL backed services
- Early failure on query or schema mismatches