DevPills #6 - SQLC: how to scaffold your database code
Published: (December 6, 2025 at 08:35 PM EST)
1 min read
Source: Dev.to
Source: Dev.to

Install
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
Create sqlc.yaml file
version: "2"
sql:
- schema: "db/schema/schema.sql"
queries: "db/queries"
engine: "postgresql"
gen:
go:
package: "sqlc"
out: "internal/infra/db/sqlc"
Define your queries (queries.sql)
-- name: ListProducts :many
SELECT * FROM products;
-- name: GetProduct :one
SELECT * FROM products WHERE id = $1;
-- name: CreateProduct :one
INSERT INTO products (name, created_at, updated_at)
VALUES ($1, $2, $3)
RETURNING id, name, created_at, updated_at;
-- name: UpdateProduct :exec
UPDATE products
SET name = $1,
updated_at = $2
WHERE id = $3;
-- name: DeleteProduct :exec
DELETE FROM products WHERE id = $1;
Generate the Go code
sqlc generate
You’re now ready to use the Go code generated by SQLC!