Skip to content
All work
Case study 13Open source

qb, a Go SQL query builder

A database-agnostic SQL query builder for Go with no ORM, no reflection and no dependencies.

RoleAuthor
Year2026
AreaOpen source
Stack
GoPostgreSQLMySQL

The brief

I wanted composable, safe SQL in Go without an ORM or reflection. The result is a small query builder that uses only the standard library.

What it does

Full statements. SELECT with joins, grouping, CTEs and subqueries. INSERT with bulk values and ON CONFLICT. UPDATE and DELETE, with RETURNING where the database supports it.

Nested conditions. A recursive predicate tree produces correctly parenthesised WHERE groups.

Correct placeholders. Indices such as $1 and $2 stay right across composed subqueries.

Dialects. PostgreSQL and MySQL are built in, behind a dialect abstraction.

Safe branching. Clone branches a shared base builder without mutating it, and typed sentinel errors make failures easy to handle.

View on GitHub

Next project
14Remote for Google TVAuthor2026