{"id":31124181,"url":"https://github.com/genesisblock3301/gquery_builder","last_synced_at":"2025-09-17T19:38:23.987Z","repository":{"id":313478319,"uuid":"1051477683","full_name":"GenesisBlock3301/gquery_builder","owner":"GenesisBlock3301","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-06T09:12:51.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-06T11:27:19.790Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GenesisBlock3301.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09-06T04:36:18.000Z","updated_at":"2025-09-06T09:12:54.000Z","dependencies_parsed_at":"2025-09-06T11:27:33.211Z","dependency_job_id":"9b165423-83dc-4a00-9831-c21ce42244cb","html_url":"https://github.com/GenesisBlock3301/gquery_builder","commit_stats":null,"previous_names":["genesisblock3301/gquery_builder"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/GenesisBlock3301/gquery_builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fgquery_builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fgquery_builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fgquery_builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fgquery_builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GenesisBlock3301","download_url":"https://codeload.github.com/GenesisBlock3301/gquery_builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenesisBlock3301%2Fgquery_builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275650063,"owners_count":25503216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"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":[],"created_at":"2025-09-17T19:38:21.028Z","updated_at":"2025-09-17T19:38:23.984Z","avatar_url":"https://github.com/GenesisBlock3301.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n| Concept       | Example                         | How we handle it in builder                                                                               |\n| ------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------- |\n| **QueryType** | SELECT, INSERT, UPDATE, DELETE  | Enum (`QueryType`) because it determines the **type of query**                                            |\n| **Clause**    | FROM, WHERE, GROUP BY, ORDER BY | Usually **hardcoded in Build()** or handled by methods, because they are **parts of a query**, not a type |\n\n\nDone:\n- Select\n- InsertInto\n- Update\n- Delete\n- From\n- Where\n- DropTable\n- DropDatabase\n\n# Go SQL Builder\n\nA simple **SQL query builder in Go** inspired by Python’s `pypika` library.  \nThis project demonstrates **builder pattern**, **interfaces**, and **polymorphism** in Go for constructing SQL queries dynamically.\n\n---\n\n## Features\n\n- **Fluent Builder Pattern**\n    - Chain methods to build queries iteratively.\n    - Example: `Query{}.From(\"customers\").Select(\"*\").Where(\"id = 1\")`.\n\n- **Supports Multiple SQL Types**\n    - `SELECT`\n    - `INSERT`\n    - `UPDATE`\n    - `DELETE`\n    - `CREATE TABLE`\n    - `DROP TABLE` / `DROP DATABASE`\n\n- **Interfaces for Polymorphism**\n    - All query builders implement a `Builder` interface with `Build()` method.\n    - Enables functions to accept **any builder** type (`SELECT`, `CREATE`, `DROP`) seamlessly.\n\n- **Extensible**\n    - Easy to add new builders like `CreateIndexBuilder`, `DropUserBuilder`.\n    - Any new builder only needs to implement `Build()` to integrate with existing functions.\n\n- **Chainable Query Building**\n    - Methods return the builder itself (`*QueryBuilder`) to allow fluent chaining.\n    - Example:\n      ```go\n      q := Query{}\n      sql := q.From(\"customers\").Select(\"*\").Where(\"id = 1\").Build()\n      ```\n\n- **Flexible Print / Execution**\n    - `PrintSQL(b Builder)` can print **any query** implementing the `Builder` interface.\n    - Example:\n      ```go\n      var b Builder = q.CreateTable(\"users\")\n      PrintSQL(b)\n      ```\n\n---\n\n## Example Usage\n\n```go\nfunc main() {\n    q := Query{}\n\n    // SELECT\n    var b Builder = q.From(\"customers\").Select(\"*\").Where(\"id = 1\")\n    PrintSQL(b) // Output: SELECT * FROM customers WHERE id = 1\n\n    // CREATE TABLE\n    b = q.CreateTable(\"users\")\n    PrintSQL(b) // Output: CREATE TABLE users (...)\n\n    // DROP DATABASE\n    b = q.DropDatabase(\"testdb\")\n    PrintSQL(b) // Output: DROP DATABASE testdb\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenesisblock3301%2Fgquery_builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenesisblock3301%2Fgquery_builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenesisblock3301%2Fgquery_builder/lists"}