{"id":15111555,"url":"https://github.com/syke99/dynaq","last_synced_at":"2025-10-08T20:49:27.967Z","repository":{"id":44376857,"uuid":"511708391","full_name":"syke99/dynaQ","owner":"syke99","description":"An extension for Go's sql package in the standard library to support dynamic queries directly from the database, as well as on individual database connections","archived":false,"fork":false,"pushed_at":"2022-07-30T14:31:28.000Z","size":98,"stargazers_count":30,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-23T16:51:34.106Z","etag":null,"topics":["database","dynamic-queries","go","golang","no-orm","orm-less","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/syke99.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":"2022-07-08T00:05:08.000Z","updated_at":"2024-01-04T17:10:03.000Z","dependencies_parsed_at":"2022-09-26T21:31:00.322Z","dependency_job_id":null,"html_url":"https://github.com/syke99/dynaQ","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/syke99/dynaQ","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syke99%2FdynaQ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syke99%2FdynaQ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syke99%2FdynaQ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syke99%2FdynaQ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syke99","download_url":"https://codeload.github.com/syke99/dynaQ/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syke99%2FdynaQ/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000640,"owners_count":26082819,"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-10-08T02:00:06.501Z","response_time":56,"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","dynamic-queries","go","golang","no-orm","orm-less","sql"],"created_at":"2024-09-26T00:21:09.474Z","updated_at":"2025-10-08T20:49:27.916Z","avatar_url":"https://github.com/syke99.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg \n    src=\"https://github.com/syke99/images/blob/main/dynaQ.png?raw=true\"\n  \u003e\n\u003c/p\u003e\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/syke99/dynaQ.svg)](https://pkg.go.dev/github.com/syke99/dynaQ)\n[![go reportcard](https://goreportcard.com/badge/github.com/syke99/dynaQ)](https://goreportcard.com/report/github.com/syke99/dynaQ)\n[![License](https://img.shields.io/github/license/syke99/dynaQ)](https://github.com/syke99/dynaQ/blob/master/LICENSE)\n![Go version](https://img.shields.io/github/go-mod/go-version/syke99/dynaQ)\u003c/br\u003e\nAn extension for Go's sql package in the standard library to support dynamic queries directly from the database, as well as on individual database connections\n\n\nHow do I use dynaQ?\n====\n\n### Installation\n\n```\ngo get github.com/syke99/dynaQ\n```\n\n### Basic Usage\n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\t\"fmt\"\n\n\t\"github.com/syke99/dynaQ\"\n\t_ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc dsn(dbName string) string {\n\treturn fmt.Sprintf(\"%s:%s@tcp(%s)/%s\", username, password, hostname, dbName)\n}\n\nfunc main() {\n\t\n  // create an instance of your database\n    db, err := sql.Open(\"mysql\", dsn(\"\"))\n    if err != nil {\n\t    panic(err)\n    }\n    defer db.Close()\n    \n    // Create a new dynamic querier with your database instance. There are two option\n    // functions you can pass in as well to deviate from the default time format \"2006-01-02 15:04\",\n    // and/or to set all individual database connections to auto-close after querying\n    dq := dynaQ.NewDynaQ(db)\n    \n    // after creating a dynamic querier, just pass in whatever\n    // query string you want, and whatever variable amouont of query\n    // arguments you need.\n    //    \n    // testTable:\n    // __| id | name | cost | available |   created-date   |__\n    // ---------------------------------------------------------\n    //   |  1 |  ab  | 2.10 |   true    | 2018-01-18 05:43 |\n    //   |  2 |  cd  | 1.55 |   false   | 2018-01-14 06:28 |\n    //   |  3 |  ef  | 3.78 |   true    | 2018-06-27 09:59 |\n    //   |  4 |  gh  | 2.76 |   true    | 2018-09-04 15:09 |\n    //   |  5 |  ij  | 8.13 |   true    | 2019-01-01 23:43 |\n    //   |  6 |  kl  | 4.45 |   false   | 2019-01-19 10:14 |\n    //   |  7 |  mn  | 2.99 |   false   | 2019-02-11 06:22 |\n    //\n    // Query the database\n    rows, err := dq.DatabaseQuery(\"select * from testTable where id in (@p1, @p2, @p3, @p4)\", 1, 2, 4, 7)\n    if err != nil {\n        panic(err)\n    }\n    \n    // create a boolean to keep track of whether or not there's a new row to be checked\n    newRow := true\n\t\n    fmt.Println(\"-----------------\")\n    for newRow {\n    \t// the first value returned by rows.NextRow()\n\t// is a bool signaling whether there is another\n\t// row following the second value returned by\n\t// rows.NextRow(), which represents the current\n\t// row for this loop\n    \tif ok, row := rows.NextRow(); !ok {\n\t\tnewRow = false\n    \t}\n    \tfmt.Println(fmt.Sprintf(\"row: %d\", row.CurrentRow))\n    \tfmt.Println(\"-----------------\")\n    \t// create a boolean to keep track of whether or not there's a new column to be checked\n\tnewColumn := true\n\tfor newColumn {\n\t\tif ok, column := row.NextColumn(); !ok {\n\t\t\tnewColumn = false\n\t\t}\n            \tfmt.Println(fmt.Sprintf(\"column: %s, value: %v (type: %s)\", column.Name, column.Value, column.Type))\n        }\n\tfmt.Println(\"-----------------\")\n    }\n    \n    //\n    // this will output:\n    // -----------------\n    // row: 1\n    // -----------------\n    // column: id, value: 1 (type: int64)\n    // column: name, value: ab (type: string)\n    // column: cost, value: 2.10 (type: float64)\n    // column: available, value: true (type: bool)\n    // column: created-date, value: 2018-01-18 05:43 (type: time.Time)\n    // -----------------\n    // row: 2\n    // -----------------\n    // column: id, value: 2 (type: int64)\n    // column: name, value: cd (type string)\n    // column: cost, value: 1.55 (type float64)\n    // column: available, value: false (type: bool)\n    // column: created-date, value: 2018-01-14 06:28 (type: time.Time)\n    // -----------------\n    // row: 3\n    // -----------------\n    // column: id, value: 4 (type: int64)\n    // column: name, value: gh (type: string)\n    // column: cost, value: 2.76 (type: float64)\n    // column: available, value: true (type: bool)\n    // column: created-date, value: 2018-09-04 15:09 (type: time.Time)\n    // -----------------\n    // row: 4\n    // -----------------\n    // column: id, value: 7 (type: int64)\n    // column: name, value: mn (type: string)\n    // column: cost, value: 2.99 (type: float64)\n    // column: available, value: false (type: bool)\n    // column: created-date, value: 2019-02-11 06:22 (type: time.Time)\n    // -----------------\n}\n```\n\n### Connections, Transactions, and PreparedStatements\n\ndynaQ also allows for using dynamic queries on database connections. After creating your dynamic querier with `dynaQ.NewDynaQ(db *sql.DB)`,\nyou can call `NewDqConn(conn *sql.Conn)` before querying to query on a specific database connection\n\n### dynaQ Usage Ideas\n\n1. SSR with html templates and dynamic queries\n2. Creating dynamic slices with values of various types from Database queries\n3. And more!! The possibilities are endless!!\n\nWho?\n====\n\nThis library was developed by Quinn Millican ([@syke99](https://github.com/syke99))\n\n\n## License\n\nThis repo is under the MIT license, see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyke99%2Fdynaq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyke99%2Fdynaq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyke99%2Fdynaq/lists"}