Quarry Docs
GitHub
Example

Scan with Quarry Query

Quarry builds the SQL. The scan layer runs it and pulls the scalar result out of the row without introducing a bigger abstraction.

Quarry logo

The query

func ActiveUserCount(qq *quarry.Quarry) quarry.SQLer {
    return qq.Select(quarry.Raw("COUNT(*)")).
        From("users").
        Where(quarry.Eq("status", "active"))
}

The query stays a Quarry value all the way until execution. That keeps the SQL shape explicit and the result contract easy to read.

Run it through scan

count, err := scan.One[int64](ctx, db, ActiveUserCount(qq))
if err != nil {
    return err
}

fmt.Println(count)
Why this example matters This is the thin path Quarry is for: build SQL explicitly, execute it through database/sql, and scan a result without pulling in a bigger row-mapping framework.

What the SQL looks like

SELECT COUNT(*)
FROM users
WHERE status = ?