{"id":36551492,"url":"https://github.com/sqlc-contrib/sqlc-gen-queries","last_synced_at":"2026-03-13T11:01:22.229Z","repository":{"id":326985339,"uuid":"1103037060","full_name":"sqlc-contrib/sqlc-gen-queries","owner":"sqlc-contrib","description":"A query generation tool that produces sqlc-compatible SQL from your database schema.","archived":false,"fork":false,"pushed_at":"2026-02-02T01:58:10.000Z","size":904,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-02T11:36:10.152Z","etag":null,"topics":["cli","generator","sqlc"],"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/sqlc-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-24T10:53:32.000Z","updated_at":"2026-02-02T01:58:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sqlc-contrib/sqlc-gen-queries","commit_stats":null,"previous_names":["sqlc-contrib/sqlc-gen-queries"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sqlc-contrib/sqlc-gen-queries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-contrib%2Fsqlc-gen-queries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-contrib%2Fsqlc-gen-queries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-contrib%2Fsqlc-gen-queries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-contrib%2Fsqlc-gen-queries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqlc-contrib","download_url":"https://codeload.github.com/sqlc-contrib/sqlc-gen-queries/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-contrib%2Fsqlc-gen-queries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30466310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T11:00:43.441Z","status":"ssl_error","status_checked_at":"2026-03-13T11:00:23.173Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["cli","generator","sqlc"],"created_at":"2026-01-12T06:35:46.482Z","updated_at":"2026-03-13T11:01:22.221Z","avatar_url":"https://github.com/sqlc-contrib.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlc-gen-queries\n\n[![CI](https://github.com/sqlc-contrib/sqlc-gen-queries/actions/workflows/ci.yml/badge.svg)](https://github.com/sqlc-contrib/sqlc-gen-queries/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/v/release/sqlc-contrib/sqlc-gen-queries?include_prereleases)](https://github.com/sqlc-contrib/sqlc-gen-queries/releases)\n[![License](https://img.shields.io/github/license/sqlc-contrib/sqlc-gen-queries)](LICENSE)\n[![Go](https://img.shields.io/badge/Go-1.25-00ADD8?logo=go\u0026logoColor=white)](https://go.dev)\n[![sqlc](https://img.shields.io/badge/sqlc-compatible-blue)](https://sqlc.dev)\n[![Coverage](https://raw.githubusercontent.com/sqlc-contrib/sqlc-gen-queries/main/.github/octocov/badge.svg)](https://github.com/sqlc-contrib/sqlc-gen-queries/actions/workflows/ci.yml)\n\nA CLI tool that generates [sqlc](https://sqlc.dev)-compatible SQL queries from your database schema catalog. Point it at a schema catalog and a configuration file, and it produces ready-to-use query files for sqlc.\n\n## Features\n\n- Generate CRUD queries (`SELECT`, `INSERT`, `UPDATE`, `DELETE`) from a database schema catalog\n- Primary key CRUD operations generated by default — no configuration needed\n- Opt-in to additional queries (List, Copy, FK joins, non-unique index queries) via `queries` allowlist\n- Configurable via YAML — shares the same `sqlc.yaml` configuration file\n- Works as a standalone CLI or as part of a CI/CD pipeline\n- Supports custom query templates\n\n## Installation\n\n```bash\ngo install github.com/sqlc-contrib/sqlc-gen-queries/cmd/sqlc-gen-queries@latest\n```\n\n## Schema Catalog\n\nThe `--catalog-file` (`schema.json` by default) is a JSON representation of your\ndatabase schema. Generate it using [Atlas](https://github.com/ariga/atlas), an\nopen-source schema management tool:\n\n```bash\natlas schema inspect \\\n  --url \"postgres://user:pass@localhost:5432/mydb?sslmode=disable\" \\\n  --format '{{ json . }}' \u003e schema.json\n```\n\nThis produces a JSON catalog containing tables, columns, indexes, primary keys,\nforeign keys, and other schema metadata that `sqlc-gen-queries` uses to generate\nqueries.\n\n## Configuration\n\n`sqlc-gen-queries` reads configuration from the same `sqlc.yaml` file used by\n[sqlc](https://sqlc.dev). To share the config file without sqlc rejecting\nunknown keys, register a dummy plugin with `true` as the command:\n\n```yaml\nversion: \"2\"\nplugins:\n  - name: gen-queries\n    process:\n      cmd: \"true\"\nsql:\n  - schema: \"schema/migration\"\n    queries: \"ent/query\"\n    engine: \"postgresql\"\n    codegen:\n      - plugin: gen-queries\n        out: \"ent/query\"\n        options:\n          queries:\n            - \"ListUsers\"\n            - \"CopyUsers\"\n            - \"GetUserWithPost\"\n```\n\n### Default queries (always generated)\n\nPrimary key CRUD operations and their Exec/Batch variants are generated\nautomatically for every table:\n\n| Query                     | Description                                |\n| ------------------------- | ------------------------------------------ |\n| `Get\u003cTable\u003e`              | Select a row by primary key                |\n| `BatchGet\u003cTables\u003e`        | Batch select rows by primary key           |\n| `Insert\u003cTable\u003e`           | Insert a row                               |\n| `ExecInsert\u003cTable\u003e`       | Insert a row (exec, returns affected rows) |\n| `BatchInsert\u003cTables\u003e`     | Batch insert rows                          |\n| `BatchExecInsert\u003cTables\u003e` | Batch insert rows (exec)                   |\n| `Update\u003cTable\u003e`           | Update a row by primary key                |\n| `ExecUpdate\u003cTable\u003e`       | Update a row by primary key (exec)         |\n| `BatchUpdate\u003cTables\u003e`     | Batch update rows by primary key           |\n| `BatchExecUpdate\u003cTables\u003e` | Batch update rows by primary key (exec)    |\n| `Delete\u003cTable\u003e`           | Delete a row by primary key                |\n| `ExecDelete\u003cTable\u003e`       | Delete a row by primary key (exec)         |\n| `BatchDelete\u003cTables\u003e`     | Batch delete rows by primary key           |\n| `BatchExecDelete\u003cTables\u003e` | Batch delete rows by primary key (exec)    |\n\n### Opt-in queries\n\nThese queries are only generated when explicitly listed in `options.queries`:\n\n| Query                           | Description                              |\n| ------------------------------- | ---------------------------------------- |\n| `List\u003cTables\u003e`                  | Paginated list with filtering            |\n| `Copy\u003cTables\u003e`                  | Bulk insert via PostgreSQL COPY protocol |\n| `Get\u003cTable\u003eWith\u003cRelated\u003e`       | Select with FK join                      |\n| `BatchGet\u003cTables\u003eWith\u003cRelated\u003e` | Batch select with FK join                |\n| `Get\u003cTable\u003eBy\u003cColumns\u003e`         | Select by non-PK unique index            |\n| `List\u003cTables\u003eBy\u003cColumns\u003e`       | Paginated list by non-unique index       |\n| `Update\u003cTables\u003eBy\u003cColumns\u003e`     | Update by non-unique index               |\n| `Delete\u003cTables\u003eBy\u003cColumns\u003e`     | Delete by non-unique index               |\n\nAll opt-in queries also have their Exec/Batch/BatchExec variants available.\n\n## Usage\n\nRun `sqlc-gen-queries` **before** `sqlc generate` so that the generated `.sql`\nquery files are available for sqlc to produce Go code:\n\n```bash\nsqlc-gen-queries --config-file sqlc.yaml --catalog-file schema.json\nsqlc generate\n```\n\n| Flag             | Environment Variable | Default       | Description                         |\n| ---------------- | -------------------- | ------------- | ----------------------------------- |\n| `--config-file`  | `SQLC_CONFIG_FILE`   | `sqlc.yaml`   | Path to the sqlc configuration file |\n| `--catalog-file` | `SQLC_CATALOG_FILE`  | `schema.json` | Path to the catalog file            |\n\n## Contributing\n\nContributions are welcome! Please open an issue or pull request.\n\nTo set up a development environment with [Nix](https://nixos.org):\n\n```bash\nnix develop\ngo test ./...\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlc-contrib%2Fsqlc-gen-queries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqlc-contrib%2Fsqlc-gen-queries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlc-contrib%2Fsqlc-gen-queries/lists"}