{"id":13412148,"url":"https://github.com/xujiajun/godbal","last_synced_at":"2025-04-24T02:07:59.709Z","repository":{"id":57496816,"uuid":"123235927","full_name":"xujiajun/godbal","owner":"xujiajun","description":"Database Abstraction Layer (dbal) for Go. Support SQL builder and get result easily  (now only support mysql)","archived":false,"fork":false,"pushed_at":"2019-01-30T05:57:00.000Z","size":52,"stargazers_count":59,"open_issues_count":0,"forks_count":29,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-24T02:07:47.540Z","etag":null,"topics":["dbal","golang","mysql","sqlbuilder"],"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/xujiajun.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":"2018-02-28T05:47:42.000Z","updated_at":"2024-02-03T19:00:49.000Z","dependencies_parsed_at":"2022-09-03T02:30:47.100Z","dependency_job_id":null,"html_url":"https://github.com/xujiajun/godbal","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xujiajun%2Fgodbal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xujiajun%2Fgodbal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xujiajun%2Fgodbal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xujiajun%2Fgodbal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xujiajun","download_url":"https://codeload.github.com/xujiajun/godbal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546081,"owners_count":21448260,"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":["dbal","golang","mysql","sqlbuilder"],"created_at":"2024-07-30T20:01:21.497Z","updated_at":"2025-04-24T02:07:59.691Z","avatar_url":"https://github.com/xujiajun.png","language":"Go","funding_links":[],"categories":["Database","数据库","Data Integration Frameworks","Generators","数据库  `go语言实现的数据库`","Uncategorized"],"sub_categories":["SQL Query Builders","SQL 查询语句构建库","Advanced Console UIs","SQL查询生成器"],"readme":"# godbal  [![GoDoc](https://godoc.org/github.com/xujiajun/godbal/driver/mysql?status.svg)](https://godoc.org/github.com/xujiajun/godbal/driver/mysql) [![GoDoc](https://godoc.org/github.com/xujiajun/godbal?status.svg)](https://godoc.org/github.com/xujiajun/godbal) [![Go Report Card](https://goreportcard.com/badge/github.com/xujiajun/godbal)](https://goreportcard.com/report/github.com/xujiajun/godbal)  \u003ca href=\"https://travis-ci.org/xujiajun/godbal\"\u003e\u003cimg src=\"https://travis-ci.org/xujiajun/godbal.svg?branch=master\" alt=\"Build Status\"\u003e\u003c/a\u003e [![Coverage Status](https://coveralls.io/repos/github/xujiajun/godbal/badge.svg?branch=master)](https://coveralls.io/github/xujiajun/godbal?branch=master)  [![License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/xujiajun/godbal/master/LICENSE) [![Awesome](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#database)\nDatabase Abstraction Layer (dbal) for go (now only support mysql)\n\n## Motivation\n\nI wanted a DBAL that ***No ORM***、***No Reflect***、***Concurrency Save***, support ***SQL builder***  following good practices and well tested code.\n\n## Requirements\n\nGo 1.7 or above.\n\n## Installation\n\n```\ngo get github.com/xujiajun/godbal\n```\n\n## Supported Databases\n\n* mysql\n\n\n## Getting Started\n\nGodbal helps you build SQL queries from composable parts easily:\n\n```\ndatabase, _ := godbal.NewMysql(\"root:123@tcp(127.0.0.1:3306)/test?charset=utf8\").Open()\nqueryBuilder := mysql.NewQueryBuilder(database)\n\tsql := queryBuilder.Select(\"uid,username,price,flag\").From(\"userinfo\", \"\").SetFirstResult(0).\n\t\tSetMaxResults(3).OrderBy(\"uid\", \"DESC\").GetSQL()\n\n\tfmt.Println(sql) \n```\n\nOutput:\n\n```\nSELECT uid,username,price,flag FROM userinfo ORDER BY uid DESC LIMIT 0,3\n```\n\nGodbal helps you get result easily:\n\n```\nrows, _ := queryBuilder.QueryAndGetMap()\njsonString, _ := json.Marshal(\u0026rows)\nfmt.Print(string(jsonString)) \n\n```\n\nOutput like:\n\n```\n {\"0\":{\"flag\":\"1\",\"price\":\"111.00\",\"uid\":\"6\",\"username\":\"johnny2\"},\"1\":{\"flag\":\"1\",\"price\":\"111.00\",\"uid\":\"5\",\"username\":\"johnny2\"},\"2\":{\"flag\":\"0\",\"price\":\"123.99\",\"uid\":\"4\",\"username\":\"joe\"}}\n```\n\n### Full example:\n\n```\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t_ \"github.com/go-sql-driver/mysql\"\n\t\"github.com/xujiajun/godbal\"\n\t\"github.com/xujiajun/godbal/driver/mysql\"\n)\n\nfunc main() {\n\tdatabase, err := godbal.NewMysql(\"root:123@tcp(127.0.0.1:3306)/test?charset=utf8\").Open()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = database.Ping()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tqueryBuilder := mysql.NewQueryBuilder(database)\n\tsql := queryBuilder.Select(\"uid,username,price,flag\").From(\"userinfo\", \"\").SetFirstResult(0).\n\t\tSetMaxResults(3).OrderBy(\"uid\", \"DESC\").GetSQL()\n\n\tfmt.Println(sql) // SELECT uid,username,price,flag FROM userinfo ORDER BY uid DESC LIMIT 0,3\n\n\trows, _ := queryBuilder.QueryAndGetMap()\n\n\tjsonString, _ := json.Marshal(\u0026rows)\n\tfmt.Print(string(jsonString)) \n  // result like: {\"0\":{\"flag\":\"1\",\"price\":\"111.00\",\"uid\":\"6\",\"username\":\"johnny2\"},\"1\":{\"flag\":\"1\",\"price\":\"111.00\",\"uid\":\"5\",\"username\":\"johnny2\"},\"2\":{\"flag\":\"0\",\"price\":\"123.99\",\"uid\":\"4\",\"username\":\"joe\"}}\n}\n\n```\n\n## More examples\n\n* [select](https://github.com/xujiajun/godbal/blob/master/examples/select/main.go)\n\n* [insert](https://github.com/xujiajun/godbal/blob/master/examples/insert/main.go)\n\n* [delete](https://github.com/xujiajun/godbal/blob/master/examples/delete/main.go)\n\n* [update](https://github.com/xujiajun/godbal/blob/master/examples/update/main.go)\n\n* [join](https://github.com/xujiajun/godbal/blob/master/examples/join/main.go)\n\n* [transaction](https://github.com/xujiajun/godbal/blob/master/examples/transaction/main.go)\n\n## Contributing\n\nIf you'd like to help out with the project. You can put up a Pull Request.\n\n## Author\n\n* [xujiajun](https://github.com/xujiajun)\n\n## License\n\nThe godbal is open-sourced software licensed under the [MIT Licensed](http://www.opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxujiajun%2Fgodbal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxujiajun%2Fgodbal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxujiajun%2Fgodbal/lists"}