turnkey-commerce/gendal ↗
Created Jan 3, 2021 · View the turnkey-commerce/gendal repository page
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, Microsoft SQL Server, and CockroachDB
Want this for your repo?
Render a free sample of any GitHub repo in seconds.
Contributors
20
Lines of Code
2,967
From
Feb 3, 2016
To
Dec 3, 2020
About turnkey-commerce/gendal
Gendal is a command-line code generator written in Go that automatically produces idiomatic Go code from database schemas. It inspects database metadata and relationships, then applies customizable Go templates to generate type definitions and database access functions. The tool supports six major relational databases: PostgreSQL, MySQL, SQLite, Oracle, Microsoft SQL Server, and CockroachDB, with varying levels of feature support across each platform.
The generator can create Go types for database tables, enums, stored procedures, and custom SQL queries. It discovers primary keys, foreign keys, and indexes automatically, translating them into well-structured Go code that reflects the underlying schema. Users can customize the output through numerous command-line flags controlling naming conventions, type mappings, template paths, and field exclusions. Gendal explicitly avoids being an ORM, instead aiming to generate efficient, type-safe, and maintainable static code that reduces boilerplate while preserving developer control over the final implementation.
The project is designed for developers who want to maintain consistency between their database schema and Go codebase without manual synchronization. It includes comprehensive examples demonstrating end-to-end workflows, custom template creation, and handling of common patterns like timestamp fields managed by the database. The tool supports integration with popular SQL drivers and offers special handling for pgx-specific features through its pgtype flag, making it adaptable to different project needs and preferences.