{"id":51236577,"url":"https://github.com/SennovE/qrafter","last_synced_at":"2026-07-04T11:00:44.709Z","repository":{"id":357193041,"uuid":"1235485959","full_name":"SennovE/qrafter","owner":"SennovE","description":"Fluent, type-safe SQL query builder for Go","archived":false,"fork":false,"pushed_at":"2026-06-15T07:03:16.000Z","size":351,"stargazers_count":43,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-06-15T09:04:48.703Z","etag":null,"topics":["database-sql","go","golang","mysql","oracle","postgresql","query-builder","sql","sqlserver","type-safe"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/SennovE/qrafter","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/SennovE.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2026-05-11T11:21:59.000Z","updated_at":"2026-06-15T07:03:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/SennovE/qrafter","commit_stats":null,"previous_names":["sennove/qrafter"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/SennovE/qrafter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SennovE%2Fqrafter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SennovE%2Fqrafter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SennovE%2Fqrafter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SennovE%2Fqrafter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SennovE","download_url":"https://codeload.github.com/SennovE/qrafter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SennovE%2Fqrafter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35118971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["database-sql","go","golang","mysql","oracle","postgresql","query-builder","sql","sqlserver","type-safe"],"created_at":"2026-06-28T21:00:25.562Z","updated_at":"2026-07-04T11:00:44.699Z","avatar_url":"https://github.com/SennovE.png","language":"Go","funding_links":[],"categories":["Database"],"sub_categories":["SQL Query Builders"],"readme":"# qrafter\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/SennovE/qrafter.svg)](https://pkg.go.dev/github.com/SennovE/qrafter)\n[![Go CI](https://github.com/SennovE/qrafter/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/SennovE/qrafter/actions/workflows/go.yml)\n[![Coverage Status](https://coveralls.io/repos/github/SennovE/qrafter/badge.svg?branch=main)](https://coveralls.io/github/SennovE/qrafter?branch=main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/SennovE/qrafter)](https://goreportcard.com/report/github.com/SennovE/qrafter)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\nqrafter is a fluent, type-safe SQL toolkit for Go. It gives you typed query\ncomposition, DDL builders, schema introspection, and generated Go migrations\nwithout becoming an ORM.\n\nUse qrafter when you want explicit SQL, typed table/column references,\ndatabase/sql compatibility, and migration files you can read and edit.\n\n## Install\n\n```sh\ngo get github.com/SennovE/qrafter\n```\n\n## Quick start\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\tq \"github.com/SennovE/qrafter\"\n\t\"github.com/SennovE/qrafter/dialect\"\n)\n\ntype User struct {\n\tq.Table `table:\"users\"`\n\n\tID       q.Column[int] `db:\"id\"`\n\tUserName q.Column[string]\n\tAge      q.Column[int]\n}\n\nfunc main() {\n\tusers := q.MustNewTable[User]()\n\n\tsql, args, err := q.Select(users.ID, users.UserName).\n\t\tWhere(\n\t\t\tusers.Age.Ge(18),\n\t\t\tusers.UserName.Eq(\"Alice\"),\n\t\t).\n\t\tOrderBy(users.ID.Asc()).\n\t\tLimit(10).\n\t\tRender(dialect.PostgreSQL{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(sql)\n\tfmt.Println(args)\n}\n```\n\nOutput:\n\n```text\nSELECT \"users\".\"id\", \"users\".\"user_name\"\nFROM \"users\"\nWHERE \"users\".\"age\" \u003e= $1 AND \"users\".\"user_name\" = $2\nORDER BY \"users\".\"id\" ASC\nLIMIT 10\n[18 Alice]\n```\n\n## Migrations\n\nThe migration tool lives in `cmd/qrafter-migrations`. It creates a Go config\nfile, compares the configured schema with the live database, generates Go\nmigration files, registers them, and applies or reverts them.\n\nShow CLI help:\n\n```sh\ngo run github.com/SennovE/qrafter/cmd/qrafter-migrations@latest help\ngo run github.com/SennovE/qrafter/cmd/qrafter-migrations@latest help revision\n```\n\nCreate `./migrations/qrafter_config.go`:\n\n```sh\ngo run github.com/SennovE/qrafter/cmd/qrafter-migrations@latest init \\\n  --dir ./migrations \\\n  --driver-import github.com/lib/pq \\\n  --driver postgres \\\n  --dialect postgres \\\n  --dsn \"postgres://app_user:app_password@localhost:5432/app_db?sslmode=disable\"\n```\n\nThe generated config is regular Go code. Add your table configs to\n`desiredSchema`:\n\n```go\npackage migrations\n\nimport (\n\t\"github.com/SennovE/qrafter/dialect\"\n\tqmig \"github.com/SennovE/qrafter/migrations\"\n\t_ \"github.com/lib/pq\"\n)\n\nvar MigrationConfig = qmig.MigrationToolConfig{\n\tDriverName:     \"postgres\",\n\tDataSourceName: \"postgres://app_user:app_password@localhost:5432/app_db?sslmode=disable\",\n\tIntrospector:   qmig.NewPostgreSQL(qmig.WithSchemas(\"public\")),\n\tDialect:        dialect.PostgreSQL{},\n\tDesired:        desiredSchema,\n\tVersionTable:   qmig.DefaultMigrationVersionTable,\n}\n\nvar Registry = []qmig.Migration{\n}\n\nfunc desiredSchema(d dialect.Renderer) qmig.Schema {\n\tvar schema qmig.Schema\n\tqmig.RegisterTable[User](\u0026schema, d) // Add your tables\n\treturn schema\n}\n```\n\nGenerate a migration from the live database diff:\n\n```sh\ngo run github.com/SennovE/qrafter/cmd/qrafter-migrations@latest revision \\\n  --dir ./migrations \\\n  --comment create_users\n```\n\nThis creates a timestamped Go file and appends it to `Registry` in\n`qrafter_config.go`. Generated migrations return `ddl.Statements`, so you can\nedit them and add custom statements such as `qddl.RawSQL(\"CREATE EXTENSION ...\")`\nwhen needed.\n\nApply or revert registered migrations:\n\n```sh\ngo run github.com/SennovE/qrafter/cmd/qrafter-migrations@latest up --dir ./migrations --to head\ngo run github.com/SennovE/qrafter/cmd/qrafter-migrations@latest down --dir ./migrations --to base\n```\n\nThe apply command stores the current version in\n`qrafter_schema_version` by default. Override it in config with\n`VersionTable` or from CLI with `--version-table`.\n\nYou can test this yourself with [examples/migrations](examples/migrations).\n\n## DDL Builders\n\nSchema statements live in the `ddl` package:\n\n```go\nsql, err := ddl.CreateTable(\"users\").\n\tColumns(\n\t\tddl.Column(\"id\", ddl.BigSerial()).PrimaryKey(),\n\t\tddl.Column(\"email\", ddl.VarChar(320)).NotNull().Unique(),\n\t\tddl.Column(\"created_at\", ddl.TimestampTZ()).DefaultExpr(\"now()\"),\n\t).\n\tRender(dialect.PostgreSQL{})\n```\n\nDDL rendering is dialect-aware and returns an error when a dialect cannot safely\nrender a requested feature.\n\n## Dialects\n\nqrafter currently includes:\n\n\ndialect     | DML | DDL | migrations\n----------- |:---:|:---:|:----------:\nBaseDialect | yes | yes | n/a\nPostgreSQL  | yes | yes | yes\nMySQL       | yes | yes | no\nSQLite      | yes | yes | no\nOracle      | yes | yes | no\nSQLServer   | yes | yes | no\n\n## Examples\n\nMore application-shaped examples live in [examples](examples):\n\n- [database_sql](examples/database_sql) shows repository-style code with\n  `database/sql`.\n- [reporting](examples/reporting) builds a larger analytical query with joins,\n  grouping, a CTE, and a window function.\n- [schema](examples/schema) renders DDL for tables, constraints, indexes, and\n  table alterations.\n- [migrations](examples/migrations) is a standalone module with Docker Compose\n  that generates, applies, and reverts qrafter migrations against PostgreSQL.\n\n## Project Status\n\nqrafter is pre-v1. The API may still change while the package evolves.\n\nContributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for the local\ndevelopment workflow and pull request guidelines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSennovE%2Fqrafter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSennovE%2Fqrafter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSennovE%2Fqrafter/lists"}