A command-line tool that generates idiomatic Go code from SQL database schemas and custom queries for PostgreSQL, MySQL, SQLite, Oracle, and SQL Server.
dbtpl is a command-line tool that generates idiomatic Go code from SQL database schemas and custom queries. It connects to databases like PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server, introspects their structure, and produces type-safe Go models and functions to interact with them, reducing manual boilerplate coding.
Go developers working with SQL databases who need to generate data access layers, models, or boilerplate code from existing schemas or custom queries efficiently.
Developers choose dbtpl for its multi-database support, customizable Go templates, and focus on generating static, type-safe code without being an ORM, allowing for greater control and adherence to idiomatic Go practices.
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works with PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server, with a detailed feature matrix in the README, making it versatile for cross-database projects.
Uses Go text templates, allowing users to dump, modify, or create templates via the --src flag, as demonstrated in the custom template quickstart for tailored code generation.
In query mode, it parses custom SQL queries and introspects related tables for accurate type mapping, ensuring compile-time safety for database operations.
Can be used with go generate for automated pipelines, as shown in the README's project template storage example, promoting consistency and ease of use.
The README explicitly states it only supports Go with no plans for other languages, limiting its utility for polyglot environments.
Requires in-depth knowledge of Go text templates and database schemas to modify base templates, which can be time-consuming for non-trivial projects.
As per the feature matrix, databases like Oracle and SQL Server lack support for ENUM types and custom types, reducing functionality for specific use cases.
For database-managed fields like timestamps, users must explicitly exclude them using flags like -e, adding overhead and potential for errors.