{"id":30703248,"url":"https://github.com/coghost/gokvsqlite","last_synced_at":"2025-09-02T16:58:01.714Z","repository":{"id":305118801,"uuid":"1021216582","full_name":"coghost/gokvsqlite","owner":"coghost","description":"sqlite(with gorm) implementation for gokv","archived":false,"fork":false,"pushed_at":"2025-07-17T06:18:18.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-18T12:46:35.663Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coghost.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,"zenodo":null}},"created_at":"2025-07-17T04:34:49.000Z","updated_at":"2025-07-17T06:17:22.000Z","dependencies_parsed_at":"2025-07-18T12:56:46.070Z","dependency_job_id":null,"html_url":"https://github.com/coghost/gokvsqlite","commit_stats":null,"previous_names":["coghost/gokvsqlite"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coghost/gokvsqlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fgokvsqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fgokvsqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fgokvsqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fgokvsqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coghost","download_url":"https://codeload.github.com/coghost/gokvsqlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fgokvsqlite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273317763,"owners_count":25084037,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-09-02T16:57:57.012Z","updated_at":"2025-09-02T16:58:01.701Z","avatar_url":"https://github.com/coghost.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gokv-sqlite (GORM-powered)\n\nA lightweight, concurrency-safe key-value store built on top of **GORM** and **SQLite**, with plug-and-play support for any GORM-compatible database such as **MySQL**, **MariaDB**, or **PostgreSQL**.\n\n---\n\n## Features\n\n- ✅ Thread-safe Set/Get/Delete\n- ✅ Uses GORM ORM layer\n- ✅ Lightweight: stores data as JSON strings\n- ✅ Supports **custom table name**\n- ✅ Easily swap backend: SQLite / MySQL / PostgreSQL / etc.\n- ✅ Auto-migration via GORM\n\n---\n\n## Installation\n\n```bash\ngo get github.com/coghost/gokvsqlite\n```\n\n---\n\n## Basic Usage (SQLite)\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/coghost/gokvsqlite\"\n)\n\ntype User struct {\n\tName string\n\tAge  int\n}\n\nfunc main() {\n\t// Create a new client with SQLite\n\tclient, err := sqlite.New(\"file=test.db?cache=shared\", \"kv_table\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer client.Close()\n\n\t// Set a value\n\terr = client.Set(\"user1\", User{Name: \"Alice\", Age: 30})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Get the value\n\tvar user User\n\tfound, err := client.Get(\"user1\", \u0026user)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif found {\n\t\tfmt.Printf(\"Found user: %+v\\n\", user)\n\t}\n\n\t// Delete the key\n\t_ = client.Delete(\"user1\")\n}\n```\n\n---\n\n## Use with MySQL / MariaDB / PostgreSQL\n\nJust replace the `gorm.Open()` logic with another driver.\n\n### Example: MySQL / MariaDB\n\n```go\nimport (\n\t\"gorm.io/driver/mysql\"\n\t\"gorm.io/gorm\"\n\t\"github.com/coghost/gokvsqlite\"\n)\n\ndsn := \"user:password@tcp(localhost:3306)/dbname?charset=utf8mb4\u0026parseTime=True\u0026loc=Local\"\ndb, err := gorm.Open(mysql.Open(dsn), \u0026gorm.Config{})\nif err != nil {\n\tpanic(err)\n}\n\nclient, err := sqlite.NewWithDB(db, \"my_kv_store\")\n```\n\n### Example: PostgreSQL\n\n```go\nimport (\n\t\"gorm.io/driver/postgres\"\n\t\"gorm.io/gorm\"\n\t\"github.com/coghost/gokvsqlite\"\n)\n\ndsn := \"host=localhost user=postgres password=yourpw dbname=yourdb port=5432 sslmode=disable\"\ndb, err := gorm.Open(postgres.Open(dsn), \u0026gorm.Config{})\n\nclient, err := sqlite.NewWithDB(db, \"pg_kv_store\")\n```\n\n\u003e ⚠️ You must import the driver explicitly:\n\u003e\n\u003e - `go get gorm.io/driver/sqlite`\n\u003e - `go get gorm.io/driver/mysql`\n\u003e - `go get gorm.io/driver/postgres`\n\n---\n\n## Thread Safety\n\nInternally uses a `sync.RWMutex` to allow safe concurrent access.\n\n## 🧪 Testing\n\nThis package includes full tests using [`stretchr/testify`](https://github.com/stretchr/testify):\n\n```bash\ngo test -v ./...\n```\n\n---\n\n## 🧩 Integration with gokv\n\nThis implementation is compatible with the [`gokv.Store`](https://pkg.go.dev/github.com/philippgille/gokv#Store) interface.\n\nYou can use it with libraries or systems that rely on the `gokv` interface abstraction.\n\n---\n\n## 🧱 Table Schema\n\nThe table (default: `kv_store`) is auto-migrated and stores:\n\n| Column | Type | Description        |\n| ------ | ---- | ------------------ |\n| `k`    | TEXT | Primary key        |\n| `v`    | TEXT | JSON-encoded value |\n\n---\n\n## License\n\nGPL-3.0 License © 2025 [Coghost](https://github.com/coghost)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoghost%2Fgokvsqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoghost%2Fgokvsqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoghost%2Fgokvsqlite/lists"}