Skip to content

sqlc

Turns your SQL queries into type-safe code for Go, Python, Kotlin and more.

Stars
18.4k
Forks
1.1k
Licence
MIT
Language
Go
Last update
4 days ago
Type
Dev tool

What it is

sqlc is a tool that reads the SQL queries you write and generates code in your programming language with type-safe functions for running them. You write the SQL yourself, run sqlc, and then call the generated functions from your application. The README says it works with PostgreSQL, MySQL and SQLite, though the list of supported databases is not shown in the excerpt provided.

  • Write a SQL query in a file, run sqlc, and call a generated Go function that returns typed results
  • Generate Python or Kotlin query code from the same SQL files used by a Go service
  • Keep database access code in sync with the schema by regenerating after changes

Great for

  • Go developers who prefer writing plain SQL over using an ORM
  • Teams that want database query mistakes caught when generating code rather than at runtime
  • Projects using Python, Kotlin or TypeScript that want generated query code via the listed sqlc-gen plugins

Not ideal for

  • People who want to avoid writing SQL entirely, since the workflow starts with hand-written queries
  • Projects needing a language not covered by the listed generators, unless they build or find a community plugin, because the README only says more languages can be added via plugins
Step-by-step guide: how to use sqlcInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    See the README

    Clone the repository

    git clone https://github.com/sqlc-dev/sqlc
  2. 2

    Run it

    • Install sqlc using the instructions at https://docs.sqlc.dev/en/latest/overview/install.html
    • Write your schema and SQL queries in files
    • Run sqlc to generate code from those files
    • Import the generated code in your application and call the functions
  3. 3

    Get the most out of it

    • Use the interactive playground at play.sqlc.dev to try queries before setting up a project
    • Pick the language generator that matches your stack from the sqlc-gen-go, sqlc-gen-kotlin, sqlc-gen-python or sqlc-gen-typescript repositories
    • Read the documentation at docs.sqlc.dev for configuration and language support details
    • Ask questions in the community Discord linked from the README

Downloads

Strengths

  • Queries stay in readable SQL that you control directly
  • Generated code gives type-safe interfaces to your queries
  • Supports multiple output languages through official and plugin generators

Trade-offs

  • You must maintain the SQL and regenerate code whenever queries or schema change
  • The excerpt does not show the full list of supported databases or language features, so check the documentation before adopting it

How it compares

ProjectStarsTypeLevelUpdatedBest for
sqlc (this)18.4kDev toolintermediate4 days agoGo developers who prefer writing plain SQL over using an ORM
sqlx17.7kLibraryintermediate2.2 years agoGo developers who already use database/sql and want less boilerplate when reading rows
gorm40kLibraryintermediate13 days agoGo developers building web services or APIs that store data in a relational database
sequelize30.3kLibraryintermediate5 days agoNode.js backend developers who use a relational SQL database
kysely14.3kLibraryintermediate4 days agoTypeScript developers who want SQL control without losing compile-time type checks
typeorm36.7kLibraryintermediate8 days agoNode.js or TypeScript developers building apps backed by a relational database

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.