A flexible and powerful SQL string builder library plus a zero-config ORM for Go.
go-sqlbuilder is a Go library for programmatically building SQL strings and acting as a zero-configuration ORM. It provides a flexible suite of builders for constructing SQL statements (SELECT, INSERT, UPDATE, etc.) that are compatible with Go's standard database/sql interfaces. It solves the problem of writing raw SQL strings manually, offering type-safe construction, argument escaping, and support for multiple database flavors.
Go developers who need to generate SQL queries dynamically, work with multiple database systems, or want a lightweight ORM alternative without the overhead of full-featured ORMs. It's particularly useful in enterprise environments with complex SQL requirements or custom database drivers.
Developers choose go-sqlbuilder for its driver-agnostic design, performance optimization, and flexibility. It avoids locking users into a specific database driver or ORM framework, supports complex SQL scenarios like nested queries and reusable WHERE clauses, and includes a zero-config ORM that works with any database/sql-compatible driver.
A flexible and powerful SQL string builder library plus a zero-config ORM.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports a comprehensive suite of builders for SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, UNION, and CTEs, with nested queries and JOINs, as shown in the README examples for complex SQL scenarios.
The Struct type acts as a lightweight ORM, generating SQL from Go structs without database connection setup, allowing use with any database/sql-compatible driver for type-safe data mapping.
WhereClause struct enables sharing and reusing conditions across different builders, improving code maintainability in enterprise environments with complex filtering logic.
Builders can be cloned to create reusable templates, avoiding repeated setup and supporting safe concurrent use, as demonstrated in the global template example.
Lacks built-in support for model relationships like joins or lazy loading; developers must manually write JOINs and manage associations, unlike full ORMs such as GORM.
The SQL interpolation feature for non-standard drivers comes with a security warning in the README, as it's less secure than using prepared statements and can be vulnerable to injection if misused.
Focuses solely on SQL string construction, so tasks like schema migrations, transaction management, or connection pooling require additional libraries or custom code.