sqlc generates type-safe code from SQL. Here's how it works:
- You write queries in SQL.
- You run sqlc to generate code with type-safe interfaces to those queries.
- 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.
Added support for enable_open_tracing
which adds open tracing to the generated code.
span, ctx := opentracing.StartSpanFromContext(ctx, "MethodName")
defer span.Finish()
version: "2"
sql:
- engine: "mysql"
queries: "query.sql"
schema: "schema.sql"
gen:
go:
emit_prepared_queries: true
emit_interface: true
enable_open_tracing: true
emit_exact_table_names: false
emit_empty_slices: true
emit_json_tags: true
package: "authors"
out: "./authors"
Additional languages can be added via plugins.