DEV.co
Open-Source Databases · sqlc-dev

sqlc

sqlc is a code generator that takes SQL queries and produces type-safe code interfaces in multiple languages (Go, Python, Kotlin, TypeScript). It bridges SQL and application code by parsing queries and generating strongly-typed functions, eliminating manual query wrapper boilerplate.

Source: GitHub — github.com/sqlc-dev/sqlc
18k
GitHub stars
1.1k
Forks
Go
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorysqlc-dev/sqlc
Ownersqlc-dev
Primary languageGo
LicenseMIT — OSI-approved
Stars18k
Forks1.1k
Open issues703
Latest releasev1.31.1 (2026-04-22)
Last updated2026-07-08
Sourcehttps://github.com/sqlc-dev/sqlc

What sqlc is

sqlc parses SQL queries against a target database schema and generates language-specific, type-safe function signatures with compile-time validation. It supports PostgreSQL, MySQL, and SQLite, with pluggable language backends via WASM plugins, enabling type checking at code generation time rather than runtime.

Quickstart

Get the sqlc source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/sqlc-dev/sqlc.gitcd sqlc# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Go microservices with strict type safety

Go teams building APIs or data-intensive services benefit from sqlc's tight integration with Go's type system, eliminating runtime type errors and enabling compile-time query validation.

Multi-language codebases requiring schema consistency

Organizations with polyglot stacks (Go + Python + Kotlin) can generate consistent, type-safe database interfaces across languages from a single SQL source of truth.

Teams prioritizing developer velocity over ORM flexibility

Projects that favor explicit SQL control and rapid prototyping over complex ORM abstractions gain from eliminating hand-written query wrappers and schema-dependent boilerplate.

Implementation considerations

  • Define SQL queries in `.sql` files and configure sqlc via `sqlc.yaml`; integrate code generation into build pipeline (CI/Makefile) to keep generated code in sync with schema.
  • Generated code is read-only and version-controlled; ensure team understands this is a build artifact and modifications must occur at the SQL layer.
  • Database schema must be accessible or mocked during code generation; manage schema versions and migrations alongside sqlc config to avoid generation failures.
  • Each supported language (Go, Python, Kotlin, TypeScript) has a separate plugin; verify plugin stability and feature parity before adopting for production in non-Go languages.
  • Plugin system (WASM-based) allows custom language support; custom plugins require plugin development expertise and may not receive same support as core generators.

When to avoid it — and what to weigh

  • Requirement for complex ORM features (relationships, eager loading, lazy loading) — sqlc is a code generator, not an ORM. It does not provide automatic relationship management, lazy loading, or query composition—teams needing Hibernate/SQLAlchemy-level abstraction should use a traditional ORM.
  • Dynamic query construction is primary pattern — sqlc requires upfront SQL query definitions. Applications that heavily build queries at runtime or use dynamic filter builders will find sqlc's compile-time model restrictive.
  • Team unfamiliar with SQL or preferring query builders — sqlc demands SQL fluency. Teams accustomed to query DSLs (Arel, LINQ) or those avoiding direct SQL may face friction; adoption requires SQL expertise.
  • Schema churn or exploratory/prototype-stage projects — Frequent schema changes require regenerating code and updating call sites. Early-stage projects with unstable schemas may incur higher maintenance burden than dynamic query engines.

License & commercial use

Licensed under MIT (permissive, OSI-approved). Permits commercial use, modification, and distribution with minimal restrictions; requires license/copyright notice retention.

MIT license explicitly permits commercial use without additional restrictions or licensing fees. No proprietary clause; suitable for closed-source products. Verify no commercial support SLA is bundled if enterprise support is required; consult terms of use for any hosted services (playground, etc.).

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

sqlc generates parameterized queries, eliminating SQL injection risk at the query level. Generated code enforces type safety. No security audit data provided. Review plugin source code if using custom language backends (WASM plugins could theoretically be attack surface, though isolation model mitigates risk). Standard Go security practices apply to the tool itself.

Alternatives to consider

sqlc alternatives: sqlx, pgx (Go-only), Gorm, SQLAlchemy (Python)

Manual query wrappers or full ORMs; trade code generation convenience for runtime flexibility or schema abstraction. sqlx/pgx require more boilerplate; ORMs abstract SQL but reduce control.

ORM-like alternatives: Prisma, TypeORM

Schema-first, language-specific; offer relationship management and migrations out-of-box. Prisma and TypeORM provide higher abstraction; sqlc stays closer to SQL with less magic.

Other code generators: XO, protoc-gen-go-sql

Similar static generation approach but smaller communities and fewer language backends. sqlc has stronger adoption and broader database support.

Software development agency

Build on sqlc with DEV.co software developers

Evaluate sqlc's fit for your project. Review documentation, try the playground, and assess schema stability and team SQL expertise. Contact us to scope implementation for your codebase.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

sqlc FAQ

Does sqlc support dynamic queries or query builders?
No. sqlc requires upfront SQL query definitions in `.sql` files. Dynamic query construction at runtime is not supported; all queries must be written in SQL and code-generated ahead of time.
Can I use sqlc with an existing migration tool (Flyway, Alembic)?
Yes. sqlc reads the final schema state; integrate it into your pipeline after migrations run. Ensure schema is in sync before running code generation to avoid errors.
Does sqlc generate ORM-like features (lazy loading, relationship traversal)?
No. sqlc generates type-safe function stubs for queries. Relationship management, eager/lazy loading, and complex ORM behaviors must be implemented manually or via a complementary ORM.
Is the Python/TypeScript/Kotlin support as mature as Go?
Unknown. The Go generator is the flagship and most widely adopted. Other language generators exist but adoption, feature parity, and maintenance velocity are not clearly stated in available data.

Software developers & web developers for hire

DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If sqlc is part of your open-source databases roadmap, our team can implement, customize, migrate, and maintain it.

Ready to add type-safe SQL to your stack?

Evaluate sqlc's fit for your project. Review documentation, try the playground, and assess schema stability and team SQL expertise. Contact us to scope implementation for your codebase.