{"id":36585966,"url":"https://github.com/whitecypher/stmts","last_synced_at":"2026-01-12T08:03:04.837Z","repository":{"id":93861339,"uuid":"101394498","full_name":"whitecypher/stmts","owner":"whitecypher","description":"Create a collection of sqlx named statements","archived":false,"fork":false,"pushed_at":"2017-08-25T11:46:01.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T15:01:56.470Z","etag":null,"topics":["collection","golang","named","sql","sqlx","statements"],"latest_commit_sha":null,"homepage":null,"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/whitecypher.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-25T10:43:06.000Z","updated_at":"2017-08-25T11:52:27.000Z","dependencies_parsed_at":"2023-04-18T05:05:02.097Z","dependency_job_id":null,"html_url":"https://github.com/whitecypher/stmts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/whitecypher/stmts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitecypher%2Fstmts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitecypher%2Fstmts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitecypher%2Fstmts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitecypher%2Fstmts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitecypher","download_url":"https://codeload.github.com/whitecypher/stmts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitecypher%2Fstmts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["collection","golang","named","sql","sqlx","statements"],"created_at":"2026-01-12T08:03:04.030Z","updated_at":"2026-01-12T08:03:04.831Z","avatar_url":"https://github.com/whitecypher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stmts \n\nThis is a utility package to create a concurrency safe collection of sqlx named statements that can be consumed in 3 stages. Registration, preparation, and execution. \n\n[![Go Report Card](https://goreportcard.com/badge/github.com/whitecypher/stmts)](https://goreportcard.com/report/github.com/whitecypher/stmts) \n[![Go Doc](https://img.shields.io/badge/reference-go%20doc-blue.svg)](https://godoc.org/github.com/whitecypher/stmts)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)]()\n\n## how to\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"database/sql\"\n  \n  \"github.com/jmoiron/sqlx\"\n  \"github.com/whitecypher/stmts\"\n)\n\n// storing queries in constants will make it easier to retrieve the queries from the collection later. The query is the key.\nconst (\n  qGetSomething = `SELECT * FROM mytable WHERE id = :id`\n  qUpdateSomething = `UPDATE mytable SET my_name_is = :name WHERE id = :id`\n  qDeleteSomething = `DELETE FROM mytable WHERE id = :id`\n)\n\nfunc main() { \n  // using sqlx for database operations\n  var db *sqlx.DB\n  \n  // TODO: resolve the connection to the database\n  \n  // collection has no dependencies so a simple declaration is sufficient.\n  var named stmts.Named\n  \n  // add queries\n  named.Add(\n    qGetSomething,\n    qUpdateSomething,\n    qDeleteSomething,\n  )\n  \n  // prepare the statements\n  err := named.Prepare(db)\n  if err != nil {\n    // TODO: handle the error however you like\n  }\n  // or use\n  named.MustPrepare(db, func(format string, v ...interface{}) { \n    // TODO: handle the error however you like\n  }) \n  \n  // retrieve and execute a query\n  var row struct {\n    ID   uint64 `db:\"id\"`\n    Name string `db:\"name\"`\n  }\n  err := named.Stmt(qGetSomething).Get(\u0026row, struct {\n    ID uint64 `db:\"id\"`\n  }{\n    ID: 1,\n  })\n  if err != nil \u0026\u0026 err != sql.ErrNoRows {\n    // TODO: handle the error however you like\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitecypher%2Fstmts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitecypher%2Fstmts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitecypher%2Fstmts/lists"}