{"id":26336153,"url":"https://github.com/dobatymo/lmdb-python-dbm","last_synced_at":"2025-07-11T14:37:12.967Z","repository":{"id":62576467,"uuid":"310166104","full_name":"Dobatymo/lmdb-python-dbm","owner":"Dobatymo","description":"Python DBM style wrapper of LMDB","archived":false,"fork":false,"pushed_at":"2024-11-13T13:02:11.000Z","size":43,"stargazers_count":35,"open_issues_count":2,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-21T03:18:11.008Z","etag":null,"topics":["dbm","lmdb","persistence","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dobatymo.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":"2020-11-05T02:08:58.000Z","updated_at":"2025-04-04T15:57:15.000Z","dependencies_parsed_at":"2024-06-19T05:22:49.426Z","dependency_job_id":"0b982a11-2b5a-4689-8501-4f8a7c2f25cf","html_url":"https://github.com/Dobatymo/lmdb-python-dbm","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.04347826086956519,"last_synced_commit":"71a27acdb1d7397fe676914d9a5998c3ed63f014"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Dobatymo/lmdb-python-dbm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dobatymo%2Flmdb-python-dbm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dobatymo%2Flmdb-python-dbm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dobatymo%2Flmdb-python-dbm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dobatymo%2Flmdb-python-dbm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dobatymo","download_url":"https://codeload.github.com/Dobatymo/lmdb-python-dbm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dobatymo%2Flmdb-python-dbm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264833290,"owners_count":23670617,"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","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":["dbm","lmdb","persistence","python"],"created_at":"2025-03-16T01:16:56.300Z","updated_at":"2025-07-11T14:37:12.923Z","avatar_url":"https://github.com/Dobatymo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lmdbm\n\nThis is a Python DBM interface style wrapper around [LMDB](http://www.lmdb.tech/doc/) (Lightning Memory-Mapped Database).\nIt uses the existing lower level Python bindings [py-lmdb](https://lmdb.readthedocs.io).\nThis is especially useful on Windows, where otherwise `dbm.dumb` is the default `dbm` database.\n\n## Install\n- `pip install lmdbm`\n\n## Example\n```python\nfrom lmdbm import Lmdb\nwith Lmdb.open(\"test.db\", \"c\") as db:\n  db[b\"key\"] = b\"value\"\n  db.update({b\"key1\": b\"value1\", b\"key2\": b\"value2\"})  # batch insert, uses a single transaction\n```\n\n### Use inheritance to store Python objects using json serialization\n\n```python\nimport json\nfrom lmdbm import Lmdb\n\nclass JsonLmdb(Lmdb):\n  def _pre_key(self, value):\n    return value.encode(\"utf-8\")\n  def _post_key(self, value):\n    return value.decode(\"utf-8\")\n  def _pre_value(self, value):\n    return json.dumps(value).encode(\"utf-8\")\n  def _post_value(self, value):\n    return json.loads(value.decode(\"utf-8\"))\n\nwith JsonLmdb.open(\"test.db\", \"c\") as db:\n  db[\"key\"] = {\"some\": \"object\"}\n  obj = db[\"key\"]\n  print(obj[\"some\"])  # prints \"object\"\n```\n\n## Warning\n\nAs of `lmdb==1.2.1` the docs say that calling `lmdb.Environment.set_mapsize` from multiple processes \"may cause catastrophic loss of data\". If `lmdbm` is used in write mode from multiple processes, set `autogrow=False` and map_size to a large enough value: `Lmdb.open(..., map_size=2**30, autogrow=False)`.\n\n## Benchmarks\n\nInstall `lmdbm[bench]` and run `benchmark.py`. Other storage engines which could be tested: `wiredtiger`, `berkeleydb`.\n\nStorage engines not benchmarked:\n- `tinydb` (because it doesn't have built-in str/bytes keys)\n\n### continuous writes in seconds (best of 3)\n| items | lmdbm  |lmdbm-batch|pysos |sqlitedict|sqlitedict-batch|dbm.dumb|semidbm|vedis |vedis-batch|unqlite|unqlite-batch|\n|------:|-------:|----------:|-----:|---------:|---------------:|-------:|------:|-----:|----------:|------:|------------:|\n|     10|   0.000|      0.015| 0.000|     0.031|           0.000|   0.016|  0.000| 0.000|      0.000|  0.000|        0.000|\n|    100|   0.094|      0.000| 0.000|     0.265|           0.016|   0.188|  0.000| 0.000|      0.000|  0.000|        0.000|\n|   1000|   1.684|      0.016| 0.015|     3.885|           0.124|   2.387|  0.016| 0.015|      0.015|  0.016|        0.000|\n|  10000|  16.895|      0.093| 0.265|    45.334|           1.326|  25.350|  0.156| 0.093|      0.094|  0.094|        0.093|\n| 100000| 227.106|      1.030| 2.698|   461.638|          12.964| 238.400|  1.623| 1.388|      1.467|  1.466|        1.357|\n|1000000|3482.520|     13.104|27.815|  5851.239|         133.396|2432.945| 16.411|15.693|     15.709| 14.508|       14.103|\n\n### random reads in seconds (best of 3)\n| items |lmdbm |lmdbm-batch|pysos |sqlitedict|sqlitedict-batch|dbm.dumb|semidbm| vedis |vedis-batch|unqlite|unqlite-batch|\n|------:|-----:|-----------|-----:|---------:|----------------|-------:|------:|------:|-----------|------:|-------------|\n|     10| 0.000|           | 0.000|     0.000|                |   0.000|  0.000|  0.000|           |  0.000|             |\n|    100| 0.000|           | 0.000|     0.031|                |   0.000|  0.000|  0.000|           |  0.000|             |\n|   1000| 0.016|           | 0.015|     0.250|                |   0.109|  0.016|  0.015|           |  0.000|             |\n|  10000| 0.109|           | 0.156|     2.558|                |   1.123|  0.171|  0.109|           |  0.109|             |\n| 100000| 1.014|           | 2.137|    27.769|                |  11.419|  2.090|  1.170|           |  1.170|             |\n|1000000|10.390|           |24.258|   447.613|                | 870.580| 22.838|214.486|           |211.319|             |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdobatymo%2Flmdb-python-dbm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdobatymo%2Flmdb-python-dbm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdobatymo%2Flmdb-python-dbm/lists"}