sqlc README

The project's README from github.com/sqlc-dev/sqlc. As one markdown file: README.md.

sqlc: A SQL Compiler

go Go Report Card

sqlc generates type-safe code from SQL. Here's how it works:

  1. You write queries in SQL.
  2. You run sqlc to generate code with type-safe interfaces to those queries.
  3. You write application code that calls the generated code.

Check out an interactive example to see it in action, and the introductory blog post for the motivation behind sqlc.

Overview

Supported languages

Additional languages can be added via plugins.

Sponsors

Development is possible thanks to our sponsors. If you would like to support sqlc, please consider sponsoring on GitHub.

Coder.com Mint.fun Mux.com

Cyberax - NaNuNaNu - Stumble - WestfalNamur - alecthomas - cameronnewman - danielbprice - davherrmann - dvob - gilcrest - gzuidhof - jeffreylo - mmcloughlin - ryohei1216 - sgielen

sqlc (sqlc-dev/sqlc)

Searching Database…

18.4K ·GitHub
What is this?sqlc is a SQL compiler: you write your queries in plain SQL, and it generates type-safe code with interfaces to those queries that your application calls.
How is that different from using an ORM?You keep writing real SQL — sqlc compiles those queries into type-safe code your app calls, instead of you maintaining table-to-object mappings by hand.
How do I get started with it?Install the sqlc binary, write your queries as SQL files, run sqlc to generate the code, then call the generated functions from your application.
Which languages can it generate code for?Go, Kotlin, Python, and TypeScript through the official sqlc-gen plugins, and further languages can be added via the plugin system.
Will it run on Windows, macOS, and Linux?Yes — sqlc is a single Go tool distributed through its Downloads page, and Go builds natively for Windows, macOS, and Linux.
Why compile SQL into code instead of using an ORM?The README points to an introductory blog post for the motivation; the idea is that your SQL stays the single source of truth while the code calling it is generated and type-safe.
Is sqlc free to use?Yes — it is MIT-licensed open source, and development is supported by GitHub Sponsors.
Does sqlc touch my database at runtime?No — it is a build-time tool: you run it to generate code, and at runtime your application just calls the generated functions like any other code in your project.
What are similar projects?ent, diesel, typeorm, usql, migrate, efcore, goose, drizzle-orm
Creator
sqlc-dev
Size
24.1 MB
Stars
18.4K
Age
7y
Commits · 90 Days