Skip to content

Protocol Buffers plugin to generate SQL schema and queries with sqlc annotations.

License

Notifications You must be signed in to change notification settings

pablojimpas/protoc-gen-sqlc

Repository files navigation

protoc-gen-sqlc

Go Reference Go CI Go Report Card

Protocol Buffers plugin to generate SQL schema and queries with sqlc annotations.

Why?

Install

You can download and compile the latest version from source using Go directly:

go install github.com/pablojimpas/protoc-gen-sqlc/cmd/protoc-gen-sqlc@latest

or you can download pre-built binaries from the Github releases page.

Usage

With buf

To use buf you have to make a config file called buf.gen.yaml with your options, like this:

version: v2
plugins:
  - local: protoc-gen-sqlc
    out: out

And then run buf generate. See the documentation on buf generate for more help.

With protoc

This plugin works with protoc as well. Here's a basic usage example:

protoc example.proto --sqlc_out=gen

General Idea

Idea diagram

Schema Build Process

Generate schema sequence diagram