{"id":15041112,"url":"https://github.com/hopehook/golang-db","last_synced_at":"2025-04-14T19:36:13.530Z","repository":{"id":57499791,"uuid":"60151601","full_name":"hopehook/golang-db","owner":"hopehook","description":"db pool helper for golang","archived":false,"fork":false,"pushed_at":"2019-03-29T08:39:36.000Z","size":28,"stargazers_count":59,"open_issues_count":0,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T08:01:41.539Z","etag":null,"topics":["db","go","mysql","pool","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","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/hopehook.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}},"created_at":"2016-06-01T06:33:58.000Z","updated_at":"2024-11-15T03:49:17.000Z","dependencies_parsed_at":"2022-08-28T15:24:04.640Z","dependency_job_id":null,"html_url":"https://github.com/hopehook/golang-db","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopehook%2Fgolang-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopehook%2Fgolang-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopehook%2Fgolang-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopehook%2Fgolang-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hopehook","download_url":"https://codeload.github.com/hopehook/golang-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248946831,"owners_count":21187582,"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","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":["db","go","mysql","pool","redis"],"created_at":"2024-09-24T20:45:36.289Z","updated_at":"2025-04-14T19:36:13.509Z","avatar_url":"https://github.com/hopehook.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# golang-db\n\ndb pool helper for golang, welcome everyone contribute code, your name will\nin CONTRIBUTORS.\n\n\n### How to use mysql pool helper\n\n1 go get github.com/hopehook/golang-db/mysql\n\n2 go get github.com/go-sql-driver/mysql\n\nNote: please use go-sql-driver Version \u003e= 1.4\n\n3 code snippet\n```go\nimport \"github.com/hopehook/golang-db/mysql\"\n\n// get a mysql db pool as global variable\nDB := mysql.InitMySQLPool(host, database, user, password, charset, maxOpenConns, maxIdleConns)\n\n// use helper function\ndata, err := DB.Query(`select * from table limit 10`)\n... ...\n\n// use transaction\nTX, _ := DB.Begin()\ndefer TX.Rollback()\nTX.Exec(`delete from table where id = 1`)\nTX.Commit()\n\n// if you want to use golang own function, please get DB.SQLDB as your db pool variable\nSQLDB := DB.SQLDB\nSQLDB.Exec(`delete from table where id = 1`)\n\n// use golang own transaction\nTX, _ := SQLDB.Begin()\ndefer TX.Rollback()\nTX.Exec(`delete from table where id = 1`)\nTX.Commit()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhopehook%2Fgolang-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhopehook%2Fgolang-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhopehook%2Fgolang-db/lists"}