GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Stumble/sqlc: Generate type-safe code from SQL (a wicked fork)

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

1,838 Commits
1,838 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
cmd
cmd
 
 
docs
docs
 
 
examples
examples
 
 
internal
internal
 
 
pkg/cli
pkg/cli
 
 
protos
protos
 
 
scripts
scripts
 
 
.gitignore
.gitignore
 
 
.readthedocs.yaml
.readthedocs.yaml
 
 
CLAUDE.md
CLAUDE.md
 
 
Dockerfile
Dockerfile
 
 
GUIDE.md
GUIDE.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
buf.gen.yaml
buf.gen.yaml
 
 
buf.lock
buf.lock
 
 
buf.work.yaml
buf.work.yaml
 
 
cliff.toml
cliff.toml
 
 
devenv.lock
devenv.lock
 
 
devenv.nix
devenv.nix
 
 
devenv.yaml
devenv.yaml
 
 
docker-compose.yml
docker-compose.yml
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
gomod_test.go
gomod_test.go
 
 
placeholder.go
placeholder.go
 
 
wicked_change_logs.md
wicked_change_logs.md
 
 

Repository files navigation

wicked-sqlc

A PostgreSQL-focused sqlc fork that generates type-safe Go code for wpgx and dcache. Write SQL; generate query methods with timeouts, optional caching, cache invalidation, replica access, and load/dump helpers for tests.

Architecture

We regularly rebase wicked-sqlc onto upstream sqlc releases. Our changes fall into two layers: compiler changes in the fork and a dedicated Go backend.

  1. Compiler — Parses SQL, resolves schema dependencies, and infers SQL types and parameter nullability. In wpgx mode, the first schema file owns the primary model; the remaining files supply dependencies and are analyzed first.
  2. Codegen contract — sqlc's GenerateRequest carries the catalog, typed queries, and comments. A small WickedMetadata extension adds the primary schema source, its relation, and top-level SELECT classification. Options such as timeout, cache, and invalidate travel as ordinary query comments, not custom compiler parameters.
  3. Wicked backend — internal/codegen/wicked maps SQL types to Go and renders the templates. It parses comment options and generates cache keys, timeout handling, invalidation hooks, replica APIs, and test helpers. The generated code uses wpgx and dcache at runtime.

The backend runs in-process, bundled in the sqlc binary. There is no separate plugin to install. sql_package: wpgx selects it; other Go configurations use upstream's standard Go backend.

Compiler fixes stay in this fork until validated with the full wicked stack, then can be proposed upstream independently. Generation-specific conventions stay in the wicked backend.

Use it

Install a release binary (Linux, macOS; the SHA-256 is checked):

curl -fsSL https://raw.githubusercontent.com/Stumble/sqlc/main/scripts/install.sh | sh -s -- v2.4.1

Or build the current main branch with the Go version specified in go.mod:

git clone https://github.com/Stumble/sqlc.git
cd sqlc
make install

See GUIDE.md for platforms, checksums and Windows.

Select the backend in sqlc.yaml:

version: '2'
sql:
  - engine: postgresql
    schema: books/schema.sql
    queries: books/query.sql
    gen:
      go:
        sql_package: wpgx
        package: books
        out: books

Every query requires a timeout. Caching is opt-in:

-- name: GetBook :one
-- -- timeout: 500ms
-- -- cache: 10m
SELECT * FROM books WHERE id = @id;

Run sqlc generate to generate code, or sqlc diff to check that it is up to date. Existing wicked projects keep the same configuration and commands.

See the guide for schema conventions, query options, and runtime setup, or bookstore for a working example. Upstream documentation covers standard sqlc features.


The original upstream README is preserved below.

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

  • Documentation
  • Installation
  • Playground
  • Website
  • Downloads
  • Community

Supported languages

  • sqlc-gen-go
  • sqlc-gen-kotlin
  • sqlc-gen-python
  • sqlc-gen-typescript

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.

Riza.io

Coder.com Mint.fun Mux.com

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

About

Generate type-safe code from SQL (a wicked fork)

sqlc.dev

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

0 watching

Forks

8 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.