finds.dev← search

// the find

xo/dbtpl

★ 3,890 · Go · MIT · updated Mar 2026

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

dbtpl (formerly xo) connects to a live database and generates type-safe Go code from the actual schema — structs, CRUD methods, index lookups, stored procs, and custom query results. It's a code generator in the stringer mold, not an ORM: you run it once (or in CI), commit the output, and the generated code is just plain Go. For teams who want SQL control without hand-writing boilerplate scanners for every table.

The template system is genuinely useful: dump the built-in templates, edit them, point `--src` at your directory, and you get exactly the methods your schema needs — not a generic interface you have to work around. Query mode is practical: you write real SQL with typed parameter placeholders (`%%name type%%`) and get a typed Go function back, no DSL. Cross-database coverage is serious — the feature matrix shows full FK, index, and stored proc support across Postgres, MySQL, SQL Server, Oracle, and SQLite, with Oracle `ALWAYS GENERATED` PK detection and MySQL `sql_mode=ansi` escape handling. The generated code is readable static Go, not reflection magic, so you can read and debug it like any other file.

Oracle support is a dead-end for most teams: the go-ora driver is not maintained at the same pace as the others, and enum/custom type support is absent for Oracle and SQL Server — you'll hit the wall on non-trivial schemas. Schema drift is your problem: if you rename a column, you re-run dbtpl and commit the diff, but nothing in the tooling catches when generated and live schema diverge in production. The tool only supports Go and says support for other languages is 'not currently planned', which limits adoption outside Go shops. Documentation for custom templates is thin beyond the examples — the template context types are in `templates/types.go` with no generated reference docs, so building non-trivial templates means reading Go source.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →