SQL Query Builders

31 projects

This subcategory sits between hand-written database/sql calls and a full ORM. It contains two kinds of tools. Query builders compose SQL strings from Go method calls at runtime. Code generators read your SQL or your database schema and produce typed Go functions and structs, so mistakes surface when you compile rather than when a query runs.

sqlc is the leading generator: you write queries in .sql files with annotations, and it generates type-safe Go for PostgreSQL, MySQL and SQLite, including for pgx. go-jet/jet generates a typed query-building DSL from your live schema, and xo generates code from schemas or custom queries. Among runtime builders, Masterminds/squirrel and doug-martin/goqu are the most used, though both have seen few changes since 2024. ozzo-dbx, sqlingo and bqb are smaller alternatives, and dotsql loads named queries from SQL files. gendry is archived. For mapping rows into structs without a builder, jmoiron/sqlx, listed under Utilities, extends database/sql.

If your queries are mostly known ahead of time, sqlc keeps SQL readable and gives typed results with no runtime reflection. Choose a runtime builder like squirrel or goqu when filters and sorting are assembled dynamically, for example in search endpoints. jet suits teams that want both type safety and dynamic composition. Always use placeholders rather than string concatenation for values.

sqlcby kyleconroy

Generate type-safe code from SQL.

github.com/sqlc-dev/sqlcGo 1.26+ 26 dependenciesv1.31.1updated today

18.4k

Squirrelby Masterminds

Go library that helps you build SQL queries.

github.com/Masterminds/squirrelGo 1.14+ 2 dependenciesv1.5.4updated 2y ago

8k

xoby knq

Generate idiomatic Go code for databases based on existing schema definitions or custom queries supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server.

github.com/xo/dbtplGo 1.26+ 16 dependenciesv1.0.2updated 1mo ago

3.9k

jetby go-jet

Framework for writing type-safe SQL queries in Go, with ability to easily convert database query result into desired arbitrary object structure.

github.com/go-jet/jet/v2Go 1.24+ 6 dependenciesv2.16.1updated 21d ago

3.8k

goquby doug-martin

Idiomatic SQL builder and query library.

github.com/doug-martin/goqu/v9Go 1.19+ 6 dependenciesv9.19.0updated 2y ago

2.7k

gendryby didi

Non-invasive SQL builder and powerful data binder.

v1.9.0archived

1.6k

Dotsqlby gchaincl

Go library that helps you keep sql files in one place and use them with ease.

github.com/qustavo/dotsqlGo 1.18+ 1 dependencyv1.2.0updated 2y ago

739

ozzo-dbxby go-ozzo

Powerful data retrieval methods as well as DB-agnostic query building capabilities.

github.com/go-ozzo/ozzo-dbxGo 1.22+ 1 dependencyv1.7.0updated 6d ago

674

sqlingoby lqs

A lightweight DSL to build SQL in Go.

v0.13.0updated 7mo ago

456

dbqby rocketlaunchr

Zero boilerplate database operations for Go.

github.com/rocketlaunchr/dbqGo 1.12+ 7 dependenciesv1.1.0updated 5y ago

417

sqrlby elgris

SQL query builder, fork of Squirrel with improved performance.

github.com/elgris/sqrl1 dependencyupdated 3y ago

285

sqby bokwoon95

Type-safe SQL builder and struct mapper for Go.

github.com/bokwoon95/go-structured-queryGo 1.14+ 8 dependenciesupdated 3y ago

200

bqbby nullism

Lightweight and easy to learn query builder.

github.com/nullism/bqbGo 1.20+ No dependencies v1.7.4updated 1y ago

195

sqlfby leporo

Fast SQL query builder.

github.com/leporo/sqlfGo 1.13+ 3 dependenciesv1.2.2updated 1y ago

189

buildsqlxby arthurkushman

Go database query builder library for PostgreSQL.

github.com/arthurkushman/buildsqlxGo 1.18+ 4 dependenciesv1.0.6updated 4mo ago

186

igorby galeone

Abstraction layer for PostgreSQL that supports advanced functionality and uses gorm-like syntax.

github.com/galeone/igorGo 1.22+ 1 dependencyupdated 2y ago

129

builqby cristalhq

Easily build SQL queries in Go.

github.com/cristalhq/builqGo 1.19+ No dependencies v0.15.0updated 2y ago

98

godbalby xujiajun

Database Abstraction Layer (dbal) for go. Support SQL builder and get result easily.

v1.0.0updated 7y ago

60

qrafterby SennovE

Type-safe SQL query builder with dialect-aware rendering, schema introspection, and migration generation.

github.com/SennovE/qrafterGo 1.18+ 1 dependencyv0.7.1updated 4mo ago

53

gosqlby twharmon

SQL Query builder with better null values support.

github.com/twharmon/gosqlGo 1.18+ 3 dependenciesv2.0.1updated 4y ago

37

qryby HnH

Tool that generates constants from files with raw SQL queries.

github.com/HnH/qryGo 1.15+ No dependencies v1.1.6updated 2y ago

35

relicaby coregx

Type-safe database query builder with zero production dependencies, LRU statement cache, batch operations, and support for JOINs, subqueries, CTEs, and window functions.

github.com/coregx/relicaGo 1.25+ No dependencies v0.20.1updated 6d ago

28

Hotcoalby motrboat

Secure your handcrafted SQL against injection.

github.com/motrboat/hotcoalGo 1.13+ No dependencies v1.1.2updated 2y ago

23

ormliteby pupizoid

Lightweight package containing some ORM-like features and helpers for sqlite databases.

github.com/pupizoid/ormliteGo 1.19+ 5 dependenciesv1.0.0updated 3y ago

15

sqlhby kirill-scherba

Zero-boilerplate SQL helper with struct tags and Go generics (CRUD, UPSERT, JOIN, benchmarks).

github.com/kirill-scherba/sqlhGo 1.25+ 4 dependenciesupdated 4mo ago

15

obreronby profe-ajedrez

Fast and cheap SQL builder which does only one thing, SQL building.

github.com/profe-ajedrez/obreronGo 1.20+ No dependencies v2.0.8updated 8mo ago

14

patcherby Jacobbrewer1

Powerful SQL Query builder that automatically generates SQL queries from structs.

github.com/jacobbrewer1/patcherGo 1.24+ 3 dependenciesv0.1.22updated 6mo ago

9

sgby go-the-way

A SQL Gen for generating standard SQLs(supports: CRUD) written in Go.

github.com/go-the-way/sgGo 1.16+ No dependencies v1.0.2updated 4y ago

7

sqlcredoby Klojer

Package for type-safe generic SQL CRUD operations with pagination, transactions, debugging, and custom raw SQL extensions.

github.com/Klojer/sqlcredoGo 1.24+ 8 dependenciesv0.9.0updated 9mo ago

3

dbaby kran

SQL query builder for hand-written SQL, adding dynamic conditions, dialect-aware placeholders, and immutable chaining.

github.com/kran/dbaGo 1.27+ 2 dependenciesupdated 1mo ago

2
S

Squalus

Thin layer over the Go SQL package that makes it easier to perform queries.

gitlab.com

Esc

Type to search every entry. ↑↓ to move, Enter to open.