{"id":38010406,"url":"https://github.com/roberth-k/qb","last_synced_at":"2026-01-16T19:19:59.915Z","repository":{"id":57491426,"uuid":"190066902","full_name":"roberth-k/qb","owner":"roberth-k","description":"SQL query builder for Go","archived":false,"fork":false,"pushed_at":"2020-05-21T22:09:27.000Z","size":145,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-14T00:34:48.435Z","etag":null,"topics":["golang","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roberth-k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-03T19:15:36.000Z","updated_at":"2023-06-03T13:18:28.000Z","dependencies_parsed_at":"2022-08-30T04:00:41.075Z","dependency_job_id":null,"html_url":"https://github.com/roberth-k/qb","commit_stats":null,"previous_names":["tetratom/qb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/roberth-k/qb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberth-k%2Fqb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberth-k%2Fqb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberth-k%2Fqb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberth-k%2Fqb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roberth-k","download_url":"https://codeload.github.com/roberth-k/qb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roberth-k%2Fqb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28481674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","sql"],"created_at":"2026-01-16T19:19:59.727Z","updated_at":"2026-01-16T19:19:59.892Z","avatar_url":"https://github.com/roberth-k.png","language":"Go","readme":"\u003ch1 align=\"center\"\u003egithub.com/tetratom/qb\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://godoc.org/github.com/tetratom/qb\"\u003e\n    \u003cimg src=\"https://godoc.org/github.com/tetratom/qb?status.svg\" alt=\"GoDoc\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://circleci.com/gh/tetratom/qb\"\u003e\n    \u003cimg src=\"https://img.shields.io/circleci/build/gh/tetratom/qb/master\" alt=\"CircleCI\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/tetratom/qb\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/tetratom/qb/master\" alt=\"Codecov\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    qb is a simple SQL query builder for Go\n\u003c/p\u003e\n\n# highlights\n\n- `go get -u github.com/tetratom/qb`\n- [GoDoc](https://godoc.org/github.com/tetratom/qb)\n- More examples can be found in [qb_test.go](./qb_test.go).\n- All methods take value receivers and return values.\n- Select the placeholder dialect with the `DialectOption(Dialect)` method.\n\n# example\n\n```go\nimport \"github.com/tetratom/qb\"\n\nq := qb.\n    Select(\"*\").From(\"my_table\").\n    Where(qb.\n        And(\"id = ?\", 1).\n        Or(\"time \u003c ?\", qb.Lit(\"now()\"))).\n    OrderBy(\"time ASC\").\n    Limit(10)\n\n// q.SQL() is \"SELECT * FROM my_table WHERE id = ?\".\n// q.Args() is []interface{1}.\nrow := tx.QueryRow(q.SQL(), q.Args()...)\n```\n\n# thread-safe and reusable builders\n\n_qb_ builders should be used the same as the `append()` built-in. The builders\ntake and return values, and internally keep state such that one builder value\ncan be re-used for different queries.  For example:\n\n```go\nqbase := qb.Select(\"col1\", \"col2\")\nq1 := qbase.From(\"t1\") // q1 is: SELECT col1, col2 FROM t1\nq2 := qbase.From(\"t2\") // q2 is: SELECT col1, col2 FROM t2\n// qbase is: SELECT col1, col2\n``` \n\nJust like with `append()`, the return value of calling a builder method must be\nassigned back into a variable to be used. For example:\n\n```go\nfunc Search(name string, ordered bool) qb.Query {\n    q := qb.Select(\"*\").From(\"members\")\n\n    if name != \"\" {\n        q = q.Where(qb.And(\"name = ?\", name))\n    }\n    \n    if ordered {\n        q = q.OrderBy(\"created_at DESC\")\n    }\n    \n    return q\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froberth-k%2Fqb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froberth-k%2Fqb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froberth-k%2Fqb/lists"}