dbtpl is a command-line code generator that produces idiomatic Go code from database schemas and SQL queries.
The tool solves the problem of manually writing boilerplate Go types and database access code by inspecting database metadata and applying customizable Go templates to discovered schema elements. It connects directly to your database, introspects tables, enums, stored procedures, and custom queries, then generates type definitions and related code. Beyond model generation, it can produce schema creation scripts, JSON and YAML schema definitions, and Graphviz diagrams. The tool operates in two modes: schema mode inspects your entire database structure, while query mode parses individual SQL queries to generate type-safe code for those specific operations.
The tool supports PostgreSQL, MySQL, Oracle, Microsoft SQL Server, and SQLite, with feature coverage varying by database. PostgreSQL and MySQL have the broadest support including enums and custom types, while all five databases support models, keys, indexes, stored procedures, and functions. Adoption suits teams working with Go who want to reduce manual schema-to-code translation and maintain consistency across database access layers. The generated code is production-quality but the tool is not positioned as a complete replacement for hand-authored SQL and Go code; it handles the repetitive structural parts while leaving room for custom logic and optimization.
The project maintains a focused scope on Go code generation with no current plans to support other languages. Development activity shows deliberate prioritization of database compatibility across major platforms rather than language expansion, suggesting the maintainers are committed to deepening support for existing databases rather than broadening the tool's scope.