# xo/dbtpl

Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server

Repository: https://github.com/xo/dbtpl
Canonical: https://ross.abutalabs.com/products/dbtpl
Language: Go
License: MIT
License Family: permissive
Topics: golang, sql, postgresql, mysql, sqlite, microsoft-sql-server, orm, code-generator, oracle
Last push: 2026-08-04T23:22:18+00:00

## Health v2 (maintenance only)
Score: 66/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 96, release rhythm 8, longevity 100
- inputs: {"age_days": 3862, "days_push": 29, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3894, forks 335 (observed 2026-08-28T04:08:28.436060+00:00)

## What it is
dbtpl is a command-line tool that inspects SQL database schemas or custom queries and generates idiomatic Go code via templates. It supports PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server, and can also emit schema scripts, JSON/YAML definitions, and Graphviz diagrams.

## Use cases
- generate Go model code from a database schema
- generate type-safe Go code from custom SQL queries
- create schema creation scripts for a database
- export database schema as JSON or YAML
- generate Graphviz diagrams of database relationships
- introspect tables, enums, and stored procedures across multiple SQL databases

## When to choose
- you write Go against SQL databases and want generated, type-safe models instead of hand-written boilerplate
- you need code generation across PostgreSQL, MySQL, SQLite, Oracle, and SQL Server with one tool
- you want customizable Go templates for generated database code
- you need schema documentation like JSON/YAML dumps or ER diagrams

## When to avoid
- you need an ORM with runtime query building rather than generated code
- you want code generation for languages other than Go
- you expect a tool that eliminates writing SQL entirely
- your project is not Go-based

## Facets
- artifact type: cli-tool
- maturity: active
- function: orm, database, templating, cli
- domain: databases, developer-tools, backend, web-development
- platform: go, cli, cross-platform
- tags: sql, code-generator, schema-introspection, go-templates, postgresql, mysql, sqlite, sql-server, oracle, code-generation

## Member repositories
- xo/dbtpl (main) score 66

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:28.436060+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:25:35.863573+00:00, confidence not recorded.
  - readme: https://github.com/xo/dbtpl (fetched 2026-08-28T04:08:28.436060+00:00, sha beea46a4864a)
- Data as of 2026-08-30T08:39:29.467469+00:00.
