A CLI and Go library for managing database schema changes through versioned SQL files or Go functions.
sqlc-dev/sqlc
A SQL compiler that reads your SQL queries and generates type-safe Go, Kotlin, Python and TypeScript code for them.
- Stars
- 18,401
- Forks
- 1,102
- Open issues
- 695
- Last commit
- 22 hours ago
What is it?
sqlc turns SQL queries into type-safe application code. You write your queries in SQL, run sqlc, and it produces functions with typed inputs and outputs that your application calls directly, instead of building queries through an ORM or string concatenation.
The tool works from your SQL schema and queries, so the generated code reflects the actual database structure. Official code generators cover Go, Kotlin, Python and TypeScript, and additional languages can be added through plugins. The project also provides an online playground for trying queries before installing it.
sqlc is written in Go and distributed under the MIT license. Its topics list PostgreSQL, MySQL and SQLite as supported database targets.
Key features
- 01Generates typed Go, Kotlin, Python and TypeScript functions from SQL queries
- 02Works from your SQL schema so generated code matches the database structure
- 03Extensible with community language plugins
- 04Includes an online playground for trying queries
Use cases
- Building Go services that talk to PostgreSQL or MySQL without an ORM
- Keeping database access code type-checked against the schema
- Generating data access layers for Python or TypeScript backends
Quick start
- 1
Install sqlc with Go using the README's install command
- 2
Read the official installation guide for other install methods
- 3
Try the interactive playground to see sqlc in action
Topics
FAQ
- What is sqlc?
- A SQL compiler that reads your SQL queries and generates type-safe Go, Kotlin, Python and TypeScript code for them. sqlc turns SQL queries into type-safe application code. You write your queries in SQL, run sqlc, and it produces functions with typed inputs and outputs that your application calls directly, instead of building queries through an ORM or string concatenation.
- Is sqlc free to use? What license does it have?
- sqlc is open source under the MIT license. Check the license terms before using it in commercial products.
- Is sqlc still maintained?
- Actively maintained. The last commit to sqlc was on Oct 21, 2026.
- What can I use sqlc for?
- Building Go services that talk to PostgreSQL or MySQL without an ORM Keeping database access code type-checked against the schema Generating data access layers for Python or TypeScript backends
- How do I install sqlc?
- Install sqlc with Go using the README's install command Read the official installation guide for other install methods Try the interactive playground to see sqlc in action
- Where can I get sqlc?
- The source code and installation instructions are on GitHub: https://github.com/sqlc-dev/sqlc
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A lightweight, framework-agnostic command-line tool for managing plain SQL database migrations across teams and environments.
A lightweight, headless TypeScript ORM for PostgreSQL, MySQL and SQLite that works across Node.js, Bun, Deno and edge runtimes.
A promise-based Node.js and TypeScript ORM for PostgreSQL, MySQL, MariaDB, SQLite, MS SQL Server, Snowflake, Oracle and Db2.
Cross-platform SQL editor and database manager for Linux, macOS, and Windows, supporting MySQL, PostgreSQL, SQLite, SQL Server and many more.
Go-based database migration tool with a CLI and library for applying ordered schema changes across many databases.