{"id":17044799,"url":"https://github.com/keredson/shadb","last_synced_at":"2026-04-18T04:31:43.224Z","repository":{"id":227334240,"uuid":"771134410","full_name":"keredson/shadb","owner":"keredson","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-13T22:54:33.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T20:06:58.109Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/keredson.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-12T18:42:57.000Z","updated_at":"2024-03-12T18:43:28.000Z","dependencies_parsed_at":"2024-03-12T19:55:59.523Z","dependency_job_id":"c0c8c650-e09a-46b9-ae74-e1abe77ab1f6","html_url":"https://github.com/keredson/shadb","commit_stats":null,"previous_names":["keredson/shadb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/keredson/shadb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fshadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fshadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fshadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fshadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keredson","download_url":"https://codeload.github.com/keredson/shadb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fshadb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31956817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"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":"2024-10-14T09:35:32.827Z","updated_at":"2026-04-18T04:31:43.204Z","avatar_url":"https://github.com/keredson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"SHADB\n=====\n\nThis is a git-backed document store with indexing.\n\nUsage\n-----\n\nLoad your database and define your indexes in python.\n\n```python\ndb = shadb.SHADB('/some/directory')\ndb.add_index('by_id', lambda o: o.get('id'), unique=True)\ndb.add_index('by_type', lambda o: o.get('type'))\n```\n\nStore a document.  If a document doesn't have an `id`, one will be generated.\n```python\n\u003e\u003e\u003e alice = {'name':'Alice', 'type':'user'}\n\u003e\u003e\u003e bob = {'name':'Bob', 'type':'user'}\n\u003e\u003e\u003e db.store(alice, bob)\n\u003e\u003e\u003e print(alice)\n{'name':'Alice', 'type':'user', 'id':'mySSkm8obM6m6MRzYJoaBH'}\n```\n\nRetrieve a document:\n```python\n\u003e\u003e\u003e db.docs.by_id['mySSkm8obM6m6MRzYJoaBH']\n{'name':'Alice', 'type':'user', 'id':'mySSkm8obM6m6MRzYJoaBH'}\n\u003e\u003e\u003e db.docs.by_type['user']\n[\n  {'name':'Alice', 'type':'user', 'id':'mySSkm8obM6m6MRzYJoaBH'},\n  {'name':'Bob', 'type':'user', 'id':'8Ry2m7WGoEZEJE3y4hTwsq'}\n]\n```\n\nIndexes support SQLite's `like` syntax:\n```python\n\u003e\u003e\u003e db.add_index('by_name', lambda o: o.get('name'))\n\u003e\u003e\u003e db.docs.by_name.keys(like='al%')\n['Alice',]\n\u003e\u003e\u003e db.docs.by_name.items(like='al%')\n[\n  ('Alice', [{'name':'Alice', 'type':'user', 'id':'mySSkm8obM6m6MRzYJoaBH'}]),\n]\n\u003e\u003e\u003e db.docs.by_name.values(like='al%')\n[{'name':'Alice', 'type':'user', 'id':'mySSkm8obM6m6MRzYJoaBH'}]\n```\n\nA document's filename can be retrieved by the index.  Filenames are automatically generated by the object's `id` and (optional) `type`.\n```python\n\u003e\u003e\u003e db.idx.by_id['mySSkm8obM6m6MRzYJoaBH']\n'user/m/y/S/S/user-mySSkm8obM6m6MRzYJoaBH.json'\n```\n\nAnd loaded by filename:\n```python\n\u003e\u003e\u003e db.load('user/m/y/S/S/user-mySSkm8obM6m6MRzYJoaBH.json')\n{'name':'Alice', 'type':'user', 'id':'mySSkm8obM6m6MRzYJoaBH'}\n```\n\n### Commits\nObjects are stored as JSON files in a git repository.  To commit, use `with`:\n\n```python\nwith db:\n  db.store({'name':'Alice', 'type':'user'})\n```\n\nTo specify a commit message:\n```python\nwith db.commit(m='a commit message') as commit:\n  commit.store({'name':'Alice', 'type':'user'})\n```\n\nTo commit outside a context manager:\n```python\nfns = db.store({'name':'Alice', 'type':'user'}, {'name':'Bob', 'type':'user'})\ndb.commit(*fns, m='a commit message')\n```\n\n\n### Object Types\nStored objects can be anything JSON serializable, plus `dataclass` and `namedtuple`.  Example:\n```python\n@dataclass\nclass User:\n   id: int\n   name: str\n\n\u003e\u003e\u003e db = shadb.SHADB('/some/directory')\n\u003e\u003e\u003e db.register(User)\n\u003e\u003e\u003e db.store(User(1, 'Alice'))\n'User/1/User-1.json'\n\u003e\u003e\u003e db.load(fn)\nUser(id=1, name='Alice')\n```\n\n\nInstall\n-------\n```bash\n$ pip install shadb\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeredson%2Fshadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeredson%2Fshadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeredson%2Fshadb/lists"}