{"id":37119318,"url":"https://github.com/tie/genji","last_synced_at":"2026-01-14T13:55:13.129Z","repository":{"id":38011234,"uuid":"301986832","full_name":"tie/genji","owner":"tie","description":"Document-oriented, embedded SQL database, works with Bolt, Badger and memory","archived":false,"fork":true,"pushed_at":"2023-03-12T10:56:37.000Z","size":3405,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-03T10:06:43.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://genji.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"chaisql/chai","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-07T09:25:09.000Z","updated_at":"2023-12-25T14:49:52.000Z","dependencies_parsed_at":"2023-02-09T21:45:35.215Z","dependency_job_id":null,"html_url":"https://github.com/tie/genji","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/tie/genji","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tie%2Fgenji","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tie%2Fgenji/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tie%2Fgenji/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tie%2Fgenji/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tie","download_url":"https://codeload.github.com/tie/genji/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tie%2Fgenji/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"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":[],"created_at":"2026-01-14T13:55:12.259Z","updated_at":"2026-01-14T13:55:13.117Z","avatar_url":"https://github.com/tie.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e Genji \u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://genji.dev\"\u003e\n    \u003cimg alt=\"Genji\" title=\"Genji\" src=\"https://raw.githubusercontent.com/genjidb/docs/master/assets/icons/logo.svg?sanitize=true\" width=\"100\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Document-oriented, embedded, SQL database\n\u003c/p\u003e\n\n## Introduction\n\n[![Build Status](https://travis-ci.org/genjidb/genji.svg)](https://travis-ci.org/genjidb/genji)\n[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/genjidb/genji)\n[![Slack channel](https://img.shields.io/badge/slack-join%20chat-green.svg)](https://gophers.slack.com/messages/CKPCYQFE0)\n![Fuzz](https://github.com/genjidb/genji/workflows/Fuzz/badge.svg)\n\nGenji is a schemaless database that allows running SQL queries on documents.\n\nCheckout the [SQL documentation](https://genji.dev/docs/genji-sql), the [Go doc](https://pkg.go.dev/github.com/genjidb/genji) and the [usage example](#usage) in the README to get started quickly.\n\n\u003e :warning: **Genji's API is still unstable**: Database compatibility is not guaranteed before reaching v1.0.0\n\n## Features\n\n- **Optional schemas**: Genji tables are schemaless, but it is possible to add constraints on any field to ensure the coherence of data within a table.\n- **Multiple Storage Engines**: It is possible to store data on disk or in ram, but also to choose between B-Trees and LSM trees. Genji relies on [BoltDB](https://github.com/etcd-io/bbolt) and [Badger](https://github.com/dgraph-io/badger) to manage data.\n- **Transaction support**: Read-only and read/write transactions are supported by default.\n- **SQL and Documents**: Genji mixes the best of both worlds by combining powerful SQL commands with JSON.\n- **Easy to use, easy to learn**: Genji was designed for simplicity in mind. It is really easy to insert and read documents of any shape.\n- **Compatible** with the `database/sql` package\n\n## Installation\n\nInstall the Genji database\n\n```bash\ngo get github.com/genjidb/genji\n```\n\n## Usage\n\nThere are two ways of using Genji, either by using Genji's API or by using the [`database/sql`](https://golang.org/pkg/database/sql/) package.\n\n### Using Genji's API\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n\n    \"github.com/genjidb/genji\"\n    \"github.com/genjidb/genji/document\"\n)\n\nfunc main() {\n    // Create a database instance, here we'll store everything on-disk using the BoltDB engine\n    db, err := genji.Open(\"my.db\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    // Don't forget to close the database when you're done\n    defer db.Close()\n\n    // Attach context, e.g. (*http.Request).Context().\n    db = db.WithContext(context.Background())\n\n    // Create a table. Schemas are optional, you don't need to specify one if not needed\n    err = db.Exec(\"CREATE TABLE user\")\n\n    // Create an index\n    err = db.Exec(\"CREATE INDEX idx_user_name ON test (name)\")\n\n    // Insert some data\n    err = db.Exec(\"INSERT INTO user (id, name, age) VALUES (?, ?, ?)\", 10, \"Foo1\", 15)\n\n    // Supported values can go from simple integers to richer data types like lists or documents\n    err = db.Exec(`\n    INSERT INTO user (id, name, age, address, friends)\n    VALUES (\n        11,\n        'Foo2',\n        20,\n        {\"city\": \"Lyon\", \"zipcode\": \"69001\"},\n        [\"foo\", \"bar\", \"baz\"]\n    )`)\n\n    // Go structures can be passed directly\n    type User struct {\n        ID              uint\n        Name            string\n        TheAgeOfTheUser float64 `genji:\"age\"`\n        Address         struct {\n            City    string\n            ZipCode string\n        }\n    }\n\n    // Let's create a user\n    u := User{\n        ID:              20,\n        Name:            \"foo\",\n        TheAgeOfTheUser: 40,\n    }\n    u.Address.City = \"Lyon\"\n    u.Address.ZipCode = \"69001\"\n\n    err = db.Exec(`INSERT INTO user VALUES ?`, \u0026u)\n\n    // Query some documents\n    res, err := db.Query(\"SELECT id, name, age, address FROM user WHERE age \u003e= ?\", 18)\n    // always close the result when you're done with it\n    defer res.Close()\n\n    // Iterate over the results\n    err = res.Iterate(func(d document.Document) error {\n        // When querying an explicit list of fields, you can use the Scan function to scan them\n        // in order. Note that the types don't have to match exactly the types stored in the table\n        // as long as they are compatible.\n        var id int\n        var name string\n        var age int32\n        var address struct {\n            City    string\n            ZipCode string\n        }\n\n        err = document.Scan(d, \u0026id, \u0026name, \u0026age, \u0026address)\n        if err != nil {\n            return err\n        }\n\n        fmt.Println(id, name, age, address)\n\n        // It is also possible to scan the results into a structure\n        var u User\n        err = document.StructScan(d, \u0026u)\n        if err != nil {\n            return err\n        }\n\n        fmt.Println(u)\n\n        // Or scan into a map\n        var m map[string]interface{}\n        err = document.MapScan(d, \u0026m)\n        if err != nil {\n            return err\n        }\n\n        fmt.Println(m)\n        return nil\n    })\n}\n\n```\n\n### Using database/sql\n\n```go\n// import Genji as a blank import\nimport _ \"github.com/genjidb/genji/sql/driver\"\n\n// Create a sql/database DB instance\ndb, err := sql.Open(\"genji\", \"my.db\")\nif err != nil {\n    log.Fatal(err)\n}\ndefer db.Close()\n\n// Then use db as usual\nres, err := db.ExecContext(...)\nres, err := db.Query(...)\nres, err := db.QueryRow(...)\n```\n\n## Engines\n\nGenji currently supports storing data in [BoltDB](https://github.com/etcd-io/bbolt), [Badger](https://github.com/dgraph-io/badger) and in-memory.\n\n### Using the BoltDB engine\n\n```go\nimport (\n    \"log\"\n\n    \"github.com/genjidb/genji\"\n)\n\nfunc main() {\n    db, err := genji.Open(\"my.db\")\n    defer db.Close()\n}\n```\n\n### Using the memory engine\n\n```go\nimport (\n    \"log\"\n\n    \"github.com/genjidb/genji\"\n)\n\nfunc main() {\n    db, err := genji.Open(\":memory:\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer db.Close()\n}\n```\n\n### Using the Badger engine\n\nFirst install the module\n\n```bash\ngo get github.com/genjidb/genji/engine/badgerengine\n```\n\n```go\nimport (\n    \"context\"\n    \"log\"\n\n    \"github.com/genjidb/genji\"\n    \"github.com/genjidb/genji/engine/badgerengine\"\n    \"github.com/dgraph-io/badger/v2\"\n)\n\nfunc main() {\n    // Create a badger engine\n    ng, err := badgerengine.NewEngine(badger.DefaultOptions(\"mydb\"))\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Pass it to genji\n    db, err := genji.New(context.Background(), ng)\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer db.Close()\n}\n```\n\n## Genji shell\n\nThe genji command line provides an SQL shell that can be used to create, modify and consult Genji databases.\n\nMake sure the Genji command line is installed:\n\n```bash\ngo get github.com/genjidb/genji/cmd/genji\n```\n\nExample:\n\n```bash\n# Opening an in-memory database:\ngenji\n\n# Opening a BoltDB database:\ngenji my.db\n\n# Opening a Badger database:\ngenji --badger pathToData\n```\n\n## Contributing\n\nContributions are welcome!\n\nSee [ARCHITECTURE.md](./ARCHITECTURE.md) and [CONTRIBUTING.md](.github/CONTRIBUTING.md).\n\nThank you, [contributors](https://github.com/genjidb/genji/graphs/contributors)!\n\nIf you have any doubt, join the [Gophers Slack channel](https://gophers.slack.com/messages/CKPCYQFE0) or open an [issue](https://github.com/genjidb/genji/issues/new).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftie%2Fgenji","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftie%2Fgenji","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftie%2Fgenji/lists"}