sqlc-gen-zz
sqlc plugin for
zombiezen.com/go/sqlite
Quick Start
Install sqlc and plugin, then sqlc generate in a project with a sqlc.yaml
with the process plugin config:
brew install sqlc
go install github.com/nzoschke/sqlc-gen-zz@latest
sqlc generate
version: "2"
plugins:
- name: zz
process:
cmd: sqlc-gen-zz
sql:
- codegen:
- out: c
plugin: zz
engine: "sqlite"
queries: "query.sql"
schema: "schema.sql"
Time Convention
If a text field ends with _at it is converted from/to a YYYY-MM-DD HH:MM:SS
string and a time.Time in support of:
created_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL
JSON Overrides
By default this will use []byte for JSON column type.
But like
sqlc JSON overrides,
you can specify a struct and this will marshal/unmarshal the struct
automatically.
Note that overrides are passed in through the plugin options.
Development
rm -rf pkg/sql/c
go install ./...
go generate ./...
go test ./...