{"id":43739239,"url":"https://github.com/mrprfrm/tinybridge","last_synced_at":"2026-02-05T11:21:36.715Z","repository":{"id":286337626,"uuid":"961056316","full_name":"mrprfrm/tinybridge","owner":"mrprfrm","description":"TinyDB bridge implementation for asyncio-based applications","archived":false,"fork":false,"pushed_at":"2025-04-27T16:38:15.000Z","size":1711,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T16:30:18.137Z","etag":null,"topics":["asyncio","python","tinydb"],"latest_commit_sha":null,"homepage":"","language":"Python","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/mrprfrm.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":"2025-04-05T16:54:59.000Z","updated_at":"2025-04-27T16:37:58.000Z","dependencies_parsed_at":"2025-04-05T20:36:58.449Z","dependency_job_id":null,"html_url":"https://github.com/mrprfrm/tinybridge","commit_stats":null,"previous_names":["mrprfrm/tinybridge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrprfrm/tinybridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrprfrm%2Ftinybridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrprfrm%2Ftinybridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrprfrm%2Ftinybridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrprfrm%2Ftinybridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrprfrm","download_url":"https://codeload.github.com/mrprfrm/tinybridge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrprfrm%2Ftinybridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29120489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T10:47:47.471Z","status":"ssl_error","status_checked_at":"2026-02-05T10:45:08.119Z","response_time":65,"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":["asyncio","python","tinydb"],"created_at":"2026-02-05T11:21:36.052Z","updated_at":"2026-02-05T11:21:36.706Z","avatar_url":"https://github.com/mrprfrm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/user-attachments/assets/48b13c90-92c8-4fd0-8f15-581ff5f4bd62\" alt=\"Alt Text\" max-height=\"450\"\u003e\n\n# tinybridge\n\nTinyDB bridge implementation for `asyncio`-based applications.\n\n**AIOBridge** is an async-safe adapter for [TinyDB](https://github.com/msiemens/tinydb), inspired by its design and intended for use within `asyncio`-based concurrent tasks. It enables safe and structured interaction with TinyDB from asynchronous Python code.\n\n### Key capabilities\n\n- Implements an async context manager for automatic resource handling\n- Ensures concurrency safety via a shared `asyncio.Lock` per DB file path\n- Executes all TinyDB operations using `asyncio.to_thread()` for non-blocking behavior\n- Provides functional-style error handling via [`Result`](https://github.com/dbrgn/result) objects\n- Supports configurable per-operation timeouts for robustness under load\n\n## Installation\n\nInstall via pip:\n\n```bash\npip install tinybridge\n```\n\nOr using [uv](https://github.com/astral-sh/uv):\n\n```bash\nuv add tinybridge\n```\n\n\u003e `tinybridge` depends on `tinydb` and `result`, both installed automatically as dependencies.\n\n## Configuration\n\n`AIOBridge` accepts the following options during initialization:\n\n| Parameter      | Type   | Default  | Description                                                   |\n| -------------- | ------ | -------- | ------------------------------------------------------------- |\n| `path`         | `str`  | —        | Path to the TinyDB JSON file                                  |\n| `timeout`      | `int`  | `10`     | Timeout (in seconds) applied to each operation                |\n| `tinydb_class` | `type` | `TinyDB` | Optional class to override the default TinyDB implementation  |\n| `**kwargs`     | `dict` | —        | Additional keyword arguments passed to the TinyDB constructor |\n\n### Customizing `tinydb_class`\n\nYou can override the default `TinyDB` class either by passing a custom class directly or by subclassing `AIOBridge`.\n\n#### Via `tinydb_class` argument\n\n```python\nfrom tinybridge import AIOBridge\nfrom tinydb import TinyDB\nfrom tinydb.storages import MemoryStorage\n\nclass InMemoryTinyDB(TinyDB):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, storage=MemoryStorage, **kwargs)\n\nasync with AIOBridge(\"db.json\", tinydb_class=InMemoryTinyDB) as db:\n    ...\n```\n\n#### By subclassing `AIOBridge`\n\n```python\nfrom tinybridge import AIOBridge\nfrom tinydb import TinyDB\nfrom tinydb.storages import JSONStorage\nfrom tinydb.middlewares import CachingMiddleware\n\nclass CustomTinyDB(TinyDB):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, storage=CachingMiddleware(JSONStorage), **kwargs)\n\nclass CustomAIOBridge(AIOBridge):\n    tinydb_class = CustomTinyDB\n```\n\n## Usage Example\n\nMinimal example demonstrating asynchronous insert:\n\n```python\nimport asyncio\nfrom tinybridge import AIOBridge\n\nasync def main():\n    async with AIOBridge(\"db.json\") as db:\n        result = await db.insert({\"name\": \"Alice\"})\n        if result.is_ok():\n            print(\"Inserted:\", result.unwrap())\n        else:\n            print(\"Insert failed:\", result.unwrap_err())\n\nasyncio.run(main())\n```\n\nAll standard TinyDB operations—such as `get`, `search`, `update`, and `remove`—are supported. Each method is wrapped for async compatibility and returns a `Result` object for safe error handling.\n\n## Similar Projects\n\nAlternative community-driven efforts to add async capabilities to TinyDB:\n\n- [`aiotinydb/aiotinydb`](https://github.com/aiotinydb/aiotinydb)\n- [`VermiIIi0n/async-tinydb`](https://github.com/VermiIIi0n/async-tinydb)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrprfrm%2Ftinybridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrprfrm%2Ftinybridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrprfrm%2Ftinybridge/lists"}