{"id":15041081,"url":"https://github.com/slicebit/qb","last_synced_at":"2025-04-04T19:11:28.596Z","repository":{"id":5734386,"uuid":"49949525","full_name":"slicebit/qb","owner":"slicebit","description":"The database toolkit for go","archived":false,"fork":false,"pushed_at":"2023-11-23T16:55:27.000Z","size":563,"stargazers_count":516,"open_issues_count":8,"forks_count":26,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-28T18:12:39.244Z","etag":null,"topics":["database","db","go","golang","mysql","orm","postgresql","sql","sqlalchemy","sqlite3"],"latest_commit_sha":null,"homepage":"http://qb.readme.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slicebit.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":"2016-01-19T11:55:06.000Z","updated_at":"2025-03-04T10:38:15.000Z","dependencies_parsed_at":"2024-06-18T17:03:33.700Z","dependency_job_id":"6cf26331-53e2-4569-9b8a-898abec09680","html_url":"https://github.com/slicebit/qb","commit_stats":{"total_commits":511,"total_committers":9,"mean_commits":56.77777777777778,"dds":0.2250489236790607,"last_synced_commit":"6bc2ae13ece37358c8795bcf0acd352c735ebf4b"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slicebit%2Fqb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slicebit%2Fqb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slicebit%2Fqb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slicebit%2Fqb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slicebit","download_url":"https://codeload.github.com/slicebit/qb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234921,"owners_count":20905854,"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":["database","db","go","golang","mysql","orm","postgresql","sql","sqlalchemy","sqlite3"],"created_at":"2024-09-24T20:45:30.683Z","updated_at":"2025-04-04T19:11:28.580Z","avatar_url":"https://github.com/slicebit.png","language":"Go","readme":"![alt text](https://github.com/slicebit/qb/raw/master/qb_logo_128.png \"qb: the database toolkit for go\")\n\n# qb - the database toolkit for go\n\n[![Build Status](https://travis-ci.org/slicebit/qb.svg?branch=master)](https://travis-ci.org/slicebit/qb)\n[![Coverage Status](https://coveralls.io/repos/github/slicebit/qb/badge.svg?branch=master)](https://coveralls.io/github/slicebit/qb?branch=master)\n[![License (LGPL version 2.1)](https://img.shields.io/badge/license-GNU%20LGPL%20version%202.1-brightgreen.svg?style=flat)](http://opensource.org/licenses/LGPL-2.1)\n[![Go Report Card](https://goreportcard.com/badge/github.com/slicebit/qb)](https://goreportcard.com/report/github.com/slicebit/qb)\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](http://godoc.org/github.com/slicebit/qb)\n\n**This project is currently pre 1.**\n\nCurrently, it's not feature complete. It can have potential bugs. There are no tests covering concurrency race conditions. It can crash especially in concurrency.\nBefore 1.x releases, each major release could break backwards compatibility.\n\nAbout qb\n--------\nqb is a database toolkit for easier db queries in go. It is inspired from python's best orm, namely sqlalchemy. qb is an orm(sqlx) as well as a query builder. It is quite modular in case of using just expression api and query building stuff.\n\n[Documentation](https://qb.readme.io)\n-------------\nThe documentation is hosted in [readme.io](https://qb.readme.io) which has great support for markdown docs. Currently, the docs are about 80% - 90% complete. The doc files will be added to this repo soon. Moreover, you can check the godoc from [here](https://godoc.org/github.com/slicebit/qb). Contributions \u0026 Feedbacks in docs are welcome.\n\nFeatures\n--------\n- Support for postgres(9.5.+), mysql \u0026 sqlite3\n- Powerful expression API for building queries \u0026 table ddls\n- Struct to table ddl mapper where initial table migrations can happen\n- Transactional session api that auto map structs to queries\n- Foreign key definitions\n- Single \u0026 Composite column indices\n- Relationships (soon.. probably in 0.3 milestone)\n\nInstallation\n------------\n```sh\ngo get -u github.com/slicebit/qb\n```\nIf you want to install test dependencies then;\n```sh\ngo get -u -t github.com/slicebit/qb\n```\n\nQuick Start\n-----------\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/slicebit/qb\"\n\t_ \"github.com/mattn/go-sqlite3\"\n    _ \"github.com/slicebit/qb/dialects/sqlite\"\n)\n\ntype User struct {\n\tID       string `db:\"id\"`\n\tEmail    string `db:\"email\"`\n\tFullName string `db:\"full_name\"`\n\tOscars   int    `db:\"oscars\"`\n}\n\nfunc main() {\n\n\tusers := qb.Table(\n\t\t\"users\",\n\t\tqb.Column(\"id\", qb.Varchar().Size(40)),\n\t\tqb.Column(\"email\", qb.Varchar()).NotNull().Unique(),\n\t\tqb.Column(\"full_name\", qb.Varchar()).NotNull(),\n\t\tqb.Column(\"oscars\", qb.Int()).NotNull().Default(0),\n\t\tqb.PrimaryKey(\"id\"),\n\t)\n\n\tdb, err := qb.New(\"sqlite3\", \"./qb_test.db\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdefer db.Close()\n\n\tmetadata := qb.MetaData()\n\n\t// add table to metadata\n\tmetadata.AddTable(users)\n\n\t// create all tables registered to metadata\n\tmetadata.CreateAll(db)\n\tdefer metadata.DropAll(db) // drops all tables\n\n\tins := qb.Insert(users).Values(map[string]interface{}{\n\t\t\"id\":        \"b6f8bfe3-a830-441a-a097-1777e6bfae95\",\n\t\t\"email\":     \"jack@nicholson.com\",\n\t\t\"full_name\": \"Jack Nicholson\",\n\t})\n\n\t_, err = db.Exec(ins)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// find user\n\tvar user User\n\n\tsel := qb.Select(users.C(\"id\"), users.C(\"email\"), users.C(\"full_name\")).\n\t\tFrom(users).\n\t\tWhere(users.C(\"id\").Eq(\"b6f8bfe3-a830-441a-a097-1777e6bfae95\"))\n\n\terr = db.Get(sel, \u0026user)\n\tfmt.Printf(\"%+v\\n\", user)\n}\n```\n\nCredits\n-------\n- [Aras Can Akın](https://github.com/aacanakin)\n- [Christophe de Vienne](https://github.com/cdevienne)\n- [Onur Şentüre](https://github.com/onursenture)\n- [Aaron O. Ellis](https://github.com/aodin)\n- [Shawn Smith](https://github.com/shawnps)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslicebit%2Fqb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslicebit%2Fqb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslicebit%2Fqb/lists"}