{"id":19665283,"url":"https://github.com/alttch/yedb-py","last_synced_at":"2026-04-28T15:36:01.389Z","repository":{"id":103749393,"uuid":"325928267","full_name":"alttch/yedb-py","owner":"alttch","description":"Rugged embedded and client/server key-value database (Python implementation)","archived":false,"fork":false,"pushed_at":"2022-09-30T23:19:11.000Z","size":243,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-01T15:13:49.735Z","etag":null,"topics":["client-server","database","iot","key-value","python","reliable","rugged"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alttch.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":"2021-01-01T06:22:39.000Z","updated_at":"2024-10-28T20:49:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"26eff884-0697-4e97-bd56-9a8fec6b82b8","html_url":"https://github.com/alttch/yedb-py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alttch/yedb-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Fyedb-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Fyedb-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Fyedb-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Fyedb-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alttch","download_url":"https://codeload.github.com/alttch/yedb-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Fyedb-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32387910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: 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":["client-server","database","iot","key-value","python","reliable","rugged"],"created_at":"2024-11-11T16:21:57.442Z","updated_at":"2026-04-28T15:35:56.380Z","avatar_url":"https://github.com/alttch.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yedb - rugged embedded and client/server key-value database (Python implementation)\n\n\u003cimg src=\"https://img.shields.io/pypi/v/yedb.svg\" /\u003e \u003cimg src=\"https://img.shields.io/badge/license-Apache%202.0-green\" /\u003e \u003cimg src=\"https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9-blue.svg\" /\u003e\n\n## Why YEDB?\n\n- Is it fast?\n- Fast to read, slow to write\n\n- Is it smart?\n- No\n\n- So what is YEDB for?\n- YEDB is ultra-reliable, thread-safe and very easy to use.\n\n- I don't like Python\n- There are other [implementations](https://yedb.bma.ai)\n\n[![Power loss data survive\ndemo](https://img.youtube.com/vi/i3hSWjrNqLo/0.jpg)](https://www.youtube.com/watch?v=i3hSWjrNqLo)\n\nhttps://www.youtube.com/watch?v=i3hSWjrNqLo\n\nYEDB is absolutely reliable rugged key-value database, which can survive in any\npower loss, unless the OS file system die. Keys data is saved in the very\nreliable way and immediately flushed to disk (this can be disabled to speed\n        up the engine but is not recommended - why then YEDB is used for).\n\n* YEDB database objects are absolutely thread-safe.\n\n* YEDB has built-in tools to automatically repair itself if any keys are broken.\n\n* If the tools failed to help, YEDB can be easily repaired by a system\nadministrator, using standard Linux tools.\n\n* YEDB can automatically validate keys with JSON Schema\n(https://json-schema.org/)\n\n* YEDB has a cool CLI\n\nPractical usage:\n\n* Create a database and start writing continuously\n\n* Turn the power switch off\n\n* Boot the machine again. The typical result: the latest saved key isn't\nsurvived, but the database is still valid and working. In 99% of cases, the\nlatest key can be automatically restored with built-in repair tools.\n\nWe created YEDB to use in our embedded products as config registry trees and\nrugged key-value data storage. We use it a lot and hope you'll like it too.\n\nNote: YEDB is good on SSDs and SD cards. As it immediately syncs all the data\nwritten, it can work on classic HDDs really slowly.\n\n## Performance\n\nModern SSDs give about 200-300 keys/sec written with auto-flush enabled. The\nwrite speed can be 10-15 times faster without it, but we would not recommend\nturning auto-flush off, as it is the key feature of YEDB.\n\nReading speed varies:\n\n* for embedded: 30-40k keys/second (70-100k keys/second when cached).\n\n* for UNIX/TCP socket: 7-15k keys/second\n\n* for HTTP: 700-800 keys/second. Transport via HTTP is mostly slow because YEDB\n  client uses synchronous \"requests\" library (while the default server is\n  async). To get better results, consider tuning the server manually and use\n  a custom async client.\n\n## Quick start\n\n```shell\n# install YEDB\npip3 install yedb\n\n# to use as embedded or client/server - go on. to use CLI - install additional\n# required libraries\npip3 install \"yedb[cli]\"\n\n# create a new database and go interactive\nyedb /path/to/my/database\n\n# set a key\nyedb set key1 value1\n# get the key value\nyedb get key1\n```\n\n## Quick client-server setup\n\n```\n# Install required system packages\n# Debian/Ubuntu: apt-get install -y --no-install-recommends python3 python3-dev gcc\n# RedHat/Fedora/CenOS: yum install -y python3 python3-devel gcc\nsudo mkdir /opt/yedbd\ncd /opt/yedbd \u0026\u0026 curl https://raw.githubusercontent.com/alttch/yedb-py/main/setup-server.sh | sudo sh\n```\n\nUse env to specify extra options:\n\n* YEDBD\\_BIND - override bind to (tcp://host:port, http://host:port or path to\n  UNIX socket)\n* YEDBD\\_SERVICE - system service name\n* YEDB\\_PS - CLI prompt\n* PIP\\_EXTRA\\_OPTIONS - specify pip extra options\n* PYTHON - override Python path\n* PIP - override pip path\n\n## Embedding\n\n```python\nfrom yedb import YEDB\n\nwith YEDB('/path/to/db', auto_repair=True) as db:\n    # do some stuff\n\n# OR\n\ndb = YEDB('/path/to/db')\ndb.open()\ntry:\n    # do some stuff\nfinally:\n    db.close()\n```\n\n## Client/server\n\n* If socket transport requested, the built-in in server requires \"msgpack\"\n  Python module\n* If HTTP transport requested, the built-in server requires \"aiohttp\" Python\n  module\n\n```shell\n# listen to tcp://localhost:8870 (default), to bind UNIX socket, specify the\n# full socket path, to use http transport, specify http://host:port to bind to\npython3 -m yedb.server /path/to/db\n```\n\n### Connect a client\n\n* If socket transport requested, the built-in in client requires \"msgpack\"\n  Python module\n* If HTTP transport requested, the built-in client requires \"requests\" Python\n  module\n\n```python\nfrom yedb import YEDB\n\nwith YEDB('tcp://localhost:8870') as db:\n    # do some stuff, remember to send all parameters as kwargs\n```\n\nYEDB creates thread-local objects. If the software is using permanent threads\nor a thread pool, it is recommended to use sessions to correctly drop these\nobjects at the end of the statement:\n\n```python\nfrom yedb import YEDB\n\nwith YEDB('tcp://localhost:8870') as db:\n    with db.session() as session:\n        # do some stuff, remember to send all parameters as kwargs\n        session.key_set(key='key1', value='val1')\n        print(session.key_get(key='key1'))\n```\n\n### Building own client\n\nYEDB uses JSON RPC (https://www.jsonrpc.org/) as the API protocol. Any method,\nlisted in yedb.server.METHODS can be called. Payloads can be packed either with\nJSON or with MessagePack.\n\nIf working via UNIX or TCP socket:\n\n* only MessagePack payload encoding is supported\n\n* Request/response format: PROTO\\_VER + DATA\\_FMT + FRAME\\_LEN(32-bit\n  little-endian) + frame\n\nWhere PROTO\\_VER = protocol version (0x01) and DATA\\_FMT = data encoding format\n(0x02 for MessagePack, which is the only protocol supported by the\nbuilt-in server).\n\n### Working with complicated data structures (embedded only)\n\n```python\nfrom yedb import YEDB\n\nwith YEDB('/path/to/db') as db:\n    with db.key_as_dict('path/to/keydict) as key:\n        key.set('field', 'value')\n    # If modified, the key is automatically saved at the end of the statement.\n```\n\n## Data formats\n\nThe default engine data format is JSON\n(https://github.com/python-rapidjson/python-rapidjson is detected and imported\n automatically if present)\n\nOther possible formats and their benefits:\n\n* YAML - (requires manually installing \"pyyaml\" Python module) slow, but key\nfiles are more human-readable and editable\n\n* msgpack - (requires manually installing \"msgpack\" Python module). Fast,\nreliable binary serialization format. If used, keys can hold binary values as\nwell.\n\n* cbor - similar to msgpack (requires manually installing \"cbor\" Python module)\n\n* pickle - native Python pickle binary data serialization format. Is slower\nthan msgpack/cbor, but keys can hold Python objects and functions as-is.\n\nDatabases can be easily converted between formats using \"yedb\" CLI tool or\n\"convert\\_fmt\" method, unless format-specific features are used (e.g. if keys\n        have binary data, they can't be converted to JSON properly).\n\n## YEDB Specifications and Data formats\n\nSee https://github.com/alttch/yedb\n\n## Schema validation\n\nAs all keys are serialized values, they can be automatically schema-validated\nwith JSON Schema (https://json-schema.org/).\n\nTo create the validation schema for the chosen key, or key group, create a\nspecial key \".schema/path/to\", which has to contain the valid JSON Schema.\n\nE.g. the schema, stored in the key \".schema/groups/group1\" will be used for\nvalidating all keys in \"groups/group1\", including the group primary key. And\nthe schema, stored in \".schema/groups/group1/key1\" will be used for validating\n\"groups/group1/key1\" only (if key or subgroup schema is present, the parent\n        schemas are omitted).\n\nYEDB also supports a non-standard scheme:\n\n```json\n{ \"type\" : \"code.python\" }\n```\n\nwhich requires the key to have valid Python code, without syntax errors.\n\nIf schema validation fails on set or structure \"with\" statement exit, an\nexception yedb.SchemaValidationError is raised.\n\n## Backup/restore\n\nFull backup: simply backup the database directory with any preferred method.\n\nPartial/server backup:\n\nUse \"dump\\_keys\" / \"load\\_keys\" methods. If dump is created with CLI (requires\n\"msgpack\" Python module for that), it has the format:\n\n    DUMP\\_VER + DUMP\\_FMT\n\n    KEY_LEN(32-bit little-endian) + KEY\n    KEY_LEN(32-bit little-endian) + KEY\n    KEY_LEN(32-bit little-endian) + KEY\n    KEY_LEN(32-bit little-endian) + KEY\n    ....\n    KEY_LEN(32-bit little-endian) + KEY\n\n## Debugging\n\nStart client/server with DEBUG=1 env variable:\n\n```shell\nDEBUG=1 yedb /path/to/db\n```\n\nto debug when embedded, enable debug logging\n\n```python\nimport yedb\n\nyedb.debug = True\n```\n\nAfter, lower the default logging level.\n\n## Module documentation\n\nhttps://yedb-py.readthedocs.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttch%2Fyedb-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falttch%2Fyedb-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttch%2Fyedb-py/lists"}