https://github.com/regb/rules_sqlc
Bazel rules for sqlc
https://github.com/regb/rules_sqlc
Last synced: 4 months ago
JSON representation
Bazel rules for sqlc
- Host: GitHub
- URL: https://github.com/regb/rules_sqlc
- Owner: regb
- License: apache-2.0
- Created: 2025-08-31T19:11:34.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-10-26T00:20:34.000Z (8 months ago)
- Last Synced: 2025-10-26T01:03:40.126Z (8 months ago)
- Language: Starlark
- Size: 122 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Bazel rules for sqlc
This is a ruleset to use [sqlc](https://github.com/sqlc-dev/sqlc) with bazel.
## Installation
Add this to your `MODULE.bazel`:
```starlark
bazel_dep(name = "rules_sqlc", dev_dependency = True)
archive_override(
module_name = "rules_sqlc",
urls = ["https://github.com/regb/rules_sqlc/archive/refs/heads/main.tar.gz"],
strip_prefix = "rules_sqlc-main",
# It is recommended to edit the above URL to a specific commit and the below sha256.
# integrity = "sha256-...",
)
sqlc = use_extension("@rules_sqlc//sqlc:extensions.bzl", "sqlc")
sqlc.toolchain(sqlc_version = "1.30.0")
```
## Quick Start
With `go` and `postgres`:
```starlark
load("@rules_sqlc//sqlc:defs.bzl", "sqlc_config", "sqlc_generate")
load("@rules_go//go:def.bzl", "go_library")
sqlc_config(
name = "config",
engine = "postgresql",
package = "db",
queries = [":query.sql"],
schema = [":schema.sql"],
)
sqlc_generate(
name = "generate",
config = ":config",
)
go_library(
name = "db",
srcs = [":generate"],
importpath = "MODULE_BASE/db",
deps = [
"@com_github_jackc_pgx_v5//:pgx",
"@com_github_jackc_pgx_v5//pgtype",
"@com_github_jackc_pgx_v5//pgconn",
],
)
```