{"id":39299827,"url":"https://github.com/torden/py-mdbm","last_synced_at":"2026-01-18T01:29:05.383Z","repository":{"id":52705837,"uuid":"115495457","full_name":"torden/py-mdbm","owner":"torden","description":"Just! Python interface for Y! MDBM, Python MDBM Wapper","archived":false,"fork":false,"pushed_at":"2022-09-02T04:01:11.000Z","size":934,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-24T16:14:41.185Z","etag":null,"topics":["database","dbm","key-value","mdbm","py-mdbm","pymdbm","pypy","pypy3","python","python3"],"latest_commit_sha":null,"homepage":"https://torden.github.io/py-mdbm/","language":"C","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/torden.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}},"created_at":"2017-12-27T07:40:30.000Z","updated_at":"2025-01-21T14:42:50.000Z","dependencies_parsed_at":"2022-08-22T08:00:27.484Z","dependency_job_id":null,"html_url":"https://github.com/torden/py-mdbm","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/torden/py-mdbm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torden%2Fpy-mdbm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torden%2Fpy-mdbm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torden%2Fpy-mdbm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torden%2Fpy-mdbm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/torden","download_url":"https://codeload.github.com/torden/py-mdbm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torden%2Fpy-mdbm/sbom","scorecard":{"id":894878,"data":{"date":"2025-08-11","repo":{"name":"github.com/torden/py-mdbm","commit":"0380a521953fc14bab6816e59375231d9d745db0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/py-mdbm.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/py-mdbm.yaml:44: update your workflow using https://app.stepsecurity.io/secureworkflow/torden/py-mdbm/py-mdbm.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/py-mdbm.yaml:80: update your workflow using https://app.stepsecurity.io/secureworkflow/torden/py-mdbm/py-mdbm.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/py-mdbm.yaml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/torden/py-mdbm/py-mdbm.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/py-mdbm.yaml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/torden/py-mdbm/py-mdbm.yaml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2022-42969"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T13:19:07.516Z","repository_id":52705837,"created_at":"2025-08-24T13:19:07.516Z","updated_at":"2025-08-24T13:19:07.516Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28526523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"ssl_error","status_checked_at":"2026-01-18T00:39:39.467Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["database","dbm","key-value","mdbm","py-mdbm","pymdbm","pypy","pypy3","python","python3"],"created_at":"2026-01-18T01:29:04.632Z","updated_at":"2026-01-18T01:29:05.342Z","avatar_url":"https://github.com/torden.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Py-mdbm\n\n- Py-mdbm is a Python binds to [Yahoo! MDBM C API.](https://github.com/yahoo/mdbm/)\n- MDBM is a super-fast memory-mapped key/value store.\n- MDBM is an ndbm work-alike hashed database library based on sdbm which is based on Per-Aake Larson’s Dynamic Hashing algorithms.\n- MDBM is a high-performance, memory-mapped hash database similar to the homegrown libhash.\n- The records stored in a mdbm database may have keys and values of arbitrary and variable lengths.\n\n|Build Stats|Py-mdbm ver.|License|Y! mdbm ver.|\n|:-:|:-:|:-:|:-:|\n[![Build Status](https://github.com/torden/py-mdbm/actions/workflows/py-mdbm.yaml/badge.svg)](https://github.com/torden/php-mdbm/actions)|[![GitHub version](https://img.shields.io/github/v/release/torden/py-mdbm)](https://github.com/torden/py-mdbm)| [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)|[![GitHub version](https://img.shields.io/github/v/release/yahoo/mdbm)](https://github.com/yahoo/mdbm)|\n\n## Table of Contents\n\n- [API](#api)\n- [Install](#install)\n- [Example](#example)\n- [Benchmark](#benchmark)\n- [Link](#link)\n\n## API\n\n### Currently Supported APIs\n\nthe following is list of support api on now.\n\n|Group|API|\n|---|---|\n|[File Management](http://yahoo.github.io/mdbm/api/group__FileManagementGroup.html)|mdbm_open, mdbm_close, mdbm_sync, mdbm_fsync, mdbm_close_fd, mdbm_replace_db, mdbm_replace_file, mdbm_dup_handle, mdbm_pre_split, mdbm_fcopy|\n|[Configuration](http://yahoo.github.io/mdbm/api/group__ConfigurationGroup.html)|mdbm_get_version, mdbm_get_size, mdbm_get_page_size, mdbm_get_limit_size, mdbm_get_hash, mdbm_get_alignment, mdbm_set_alignment, mdbm_setspillsize, mdbm_limit_dir_size,  mdbm_get_magic_number, *~~mdbm_limit_size_v3, mdbm_set_window_size~~*|\n|[Record Access](http://yahoo.github.io/mdbm/api/group__RecordAccessGroup.html)|mdbm_fetch, mdbm_delete, mdbm_store, mdbm_fetch_r, mdbm_fetch_dup_r, mdbm_delete_r, mdbm_store_r, mdbm_fetch_info|\n|[Record Iteration](http://yahoo.github.io/mdbm/api/group__RecordIterationGroup.html)|mdbm_first, mdbm_next, mdbm_firstkey, mdbm_nextkey, mdbm_first_r, mdbm_next_r, mdbm_firstkey_r, mdbm_nextkey_r, *~~mdbm_iterate~~*|\n|[Locking](http://yahoo.github.io/mdbm/api/group__LockingGroup.html)|mdbm_islocked, mdbm_isowned, mdbm_lock, mdbm_unlock, mdbm_lock_reset, mdbm_delete_lockfiles,  mdbm_get_lockmode, mdbm_trylock, mdbm_plock, mdbm_punlock, mdbm_tryplock, mdbm_lock_shared, mdbm_trylock_shared, mdbm_lock_smart, mdbm_trylock_smart, mdbm_unlock_smart|\n|[Data Management](http://yahoo.github.io/mdbm/api/group__DataManagementGroup.html)|mdbm_compress_tree, mdbm_truncate, mdbm_purge, mdbm_clean, *~~mdbm_prune, mdbm_set_cleanfunc~~*|\n|[Data Integrity](http://yahoo.github.io/mdbm/api/group__DataIntegrityGroup.html)|mdbm_check, mdbm_chk_all_page, mdbm_chk_page, mdbm_protect|\n|[Data Display](http://yahoo.github.io/mdbm/api/group__DataDisplayGroup.html)|mdbm_dump_all_page, mdbm_dump_page|\n|[Statistics](http://yahoo.github.io/mdbm/api/group__StatisticsGroup.html)|mdbm_count_records, mdbm_count_pages, mdbm_get_stats, mdbm_get_db_info, mdbm_get_stat_counter, mdbm_get_stat_time, mdbm_reset_stat_operations, mdbm_enable_stat_operations, mdbm_set_stat_time_func, mdbm_get_db_stats, mdbm_get_window_stats, *~~mdbm_get_stat_name, mdbm_set_stats_func, mdbm_chunk_iterate~~*|\n|[Cache and Backing Store](http://yahoo.github.io/mdbm/api/group__CacheAndBackingStoreGroup.html)|mdbm_set_cachemode, mdbm_get_cachemode, mdbm_get_cachemode_name, *~~mdbm_set_backingstore~~*|\n|[Import and Export](http://yahoo.github.io/mdbm/api/group__ImportExportGroup.html)|*~~mdbm_cdbdump_to_file, mdbm_cdbdump_trailer_and_close, mdbm_cdbdump_add_record, mdbm_dbdump_to_file, mdbm_dbdump_trailer_and_close, mdbm_dbdump_add_record, mdbm_dbdump_export_header, mdbm_dbdump_import_header, mdbm_dbdump_import, mdbm_cdbdump_import~~*|\n|[Miscellaneous](http://yahoo.github.io/mdbm/api/group__MiscellaneousGroup.html)|mdbm_preload, mdbm_get_errno,  mdbm_get_page, mdbm_lock_pages, mdbm_unlock_pages, mdbm_get_hash_value, mdbm_select_log_plugin, mdbm_set_log_filename|\n\n### Deprecated APIs\n\n|*API*|*STATUS*|*COMMENT*|\n|---|---|---|\n|mdbm_save|DEPRECATED|mdbm_save is only supported for V2 MDBMs.|\n|mdbm_restore|DEPRECATED|mdbm_restore is only supported for V2 MDBMs.|\n|mdbm_sethash|DEPRECATED|Legacy version of mdbm_set_hash() This function has inconsistent naming, an error return value. It will be removed in a future version.|\n\n### Only a V2 implementation\n\n|*API*|*STATUS*|*COMMENT*|\n|---|---|---|\n|mdbm_stat_all_page|V3 not supported|There is only a V2 implementation. V3 not currently supported.|\n|mdbm_stat_header|V3 not supported|There is only a V2 implementation. V3 not currently supported.|\n\n### Has not been implemented\n\n|*API*|*STATUS*|*COMMENT*|\n|---|---|---|\n|dbm_chk_error|Not Implemented|This has not been implemented|\n\n\n## Support two compatibility version\n\n### Python\n\n|*Version*|*Support*|*Test*|\n|---|---|---|\n|Python 2.6.x ~ 2.7.x|yes|always|\n|Python 3.0.x ~ 3.x.x|yes|always|\n|PyPy|yes|always|\n|PyPy3|yes|always|\n\n### MDBM\n\n|*branch or release ver.*|*Support*|*Test*|*Comment*|\n|---|---|---|---|\n|master|yes|always|\n|4.x|yes|always|\n\n## Install\n\n### MDBM\n\n- [MDBM Packages](https://github.com/torden/mdbm)\n\n### py-mdbm (use pip)\n\n```shell\npip install py-mdbm\n```\n\n### py-mdbm (use source)\n\n#### Download\n\n```shell\ngit clone https://github.com/torden/py-mdbm\n```\n\n#### Build and Test\n\n```shell\ncd py-mdbm\nCMD_PYTHON=`which python` make\n```\n\n### Check\n\n```shell\n$ python\n\u003e\u003e\u003e import mdbm\n\u003e\u003e\u003e help(mdbm)\n```\n\n### Benchmark\n\n```shell\ncd py-mdbm\n`which pip` install -r for-benchmark-py26_or_higher-requirements.txt\nCMD_PYTHON=`which python` CMD_PYTEST=`which pytest` make benchmark\n```\n\n## Example\n\nSee the [Source Code](https://github.com/torden/py-mdbm/tree/master/example) for more details\n\nThe following is Sample codes for a first look at py-mdbm\n\n### Creating and populating a database\n\n#### Python 2 or higher\n\n```python\nimport mdbm\nimport random\n\nprint(\"[*] Creating and populating a database\")\n\npath = \"/tmp/test1.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nflags = flags | mdbm.MDBM_O_CREAT\nflags = flags | mdbm.MDBM_LARGE_OBJECTS\nflags = flags | mdbm.MDBM_ANY_LOCKS\nflags = flags | mdbm.MDBM_O_TRUNC\nmode = 0o644  # means 0644\n\ndbm = mdbm.open(path, flags, mode)\nfor i in range(0, 65535):\n    k = str(i)\n    v = str(random.randrange(0, 65535))\n\n    rv = dbm.store(k, v, mdbm.MDBM_INSERT)\n    if not rv:\n        print(\"[-] failed to data store to \", path)\n        break\n\nprint(\"[*] count of records : %d\" % dbm.count_records())\n\ndbm.close()\n\nprint(\"done\")\n```\n\n#### Python 3 or higher\n\n```python\n# encoding: utf-8\nimport mdbm\nimport random\n\nprint(\"[*] Creating and populating a database\")\n\npath = \"/tmp/test1-byte.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nflags = flags | mdbm.MDBM_O_CREAT\nflags = flags | mdbm.MDBM_LARGE_OBJECTS\nflags = flags | mdbm.MDBM_ANY_LOCKS\nflags = flags | mdbm.MDBM_O_TRUNC\nmode = 0o644  # means 0644\n\ndbm = mdbm.open(path, flags, mode)\n\nprint(\"|--------|-------|\")\nprint(\"|  key   |  val  |\")\nprint(\"|--------|-------|\")\n\n# byte\nfor i in range(0, 10):\n    k = bytes(str(i), 'utf-8')\n    v = bytes(str(random.randrange(0, 65535)), 'utf-8')\n\n    print(\"|%08s|%08s|\" % (k, v))\n    rv = dbm.store(k, v, mdbm.MDBM_INSERT|mdbm.MDBM_CACHE_MODIFY)\n    if not rv:\n        print(\"[-] failed to data store to \", path)\n        break\n\n# string\nfor i in range(10, 20):\n    k = str(i)\n    v = str(random.randrange(0, 65535))\n\n    print(\"|%08s|%08s|\" % (k, v))\n\n\n    rv = dbm.store(k, v, mdbm.MDBM_INSERT|mdbm.MDBM_CACHE_MODIFY)\n    if not rv:\n        print(\"[-] failed to data store to \", path)\n        break\n\n\nprint(\"|--------|--------|\")\nprint(\"[*] count of records : %d\" % dbm.count_records())\nprint(\"\\n\")\n\ndbm.close()\n\n```\n\n### Fetching records in-place\n\n```python\nimport mdbm\nimport random\n\nprint(\"[*] Fetching records in-place\")\n\npath = \"/tmp/test1.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nmode = 0o644  # means 0644\n\ndbm = mdbm.open(path, flags, mode)\ndbm.preload()\n\nprint(\"|-------|-------|\")\nprint(\"|  key  |  val  |\")\nprint(\"|-------|-------|\")\n\nfor i in range(0, 10):\n\n    k = str(random.randrange(0, 65534))\n    orgval = dbm.fetch(k)\n    if not orgval:\n        print(\"[-] failed to fetch value of %s in mdbm\" % k)\n        break\n\n    print(\"|%07s|%07s|\" % (k, orgval))\n\nprint(\"|-------|-------|\")\nprint(\"[*] count of records : %d\" % dbm.count_records())\n\ndbm.close()\n\nprint(\"done\")\n```\n\n### Fetching and updating records in-place\n\n```python\nimport mdbm\nimport random\n\nprint(\"[*] Fetching and updating records in-place\")\n\npath = \"/tmp/test1.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nmode = 0o644  # means 0644\n\ndbm = mdbm.open(path, flags, mode)\nfor i in range(0, 65535):\n    k = str(i)\n    v = str(random.randrange(0, 65535))\n\n    orgval = dbm.fetch(k)\n    if not orgval:\n        print(\"[-] failed to fetch value of %s in mdbm\" % k)\n        break\n\n    print(\"[=] key(%s) : replace val(%s) to '%s' : \" % (k, orgval, v)),\n\n    rv = dbm.store(k, v, mdbm.MDBM_REPLACE)\n    if not rv:\n        print(\"FAIL\")\n        break\n    print(\"DONE\")\n\nprint(\"[*] count of records : %d\" % dbm.count_records())\n\ndbm.close()\n\nprint(\"done\")\n```\n\n### Deleting records in-place\n\n```python\nimport mdbm\nimport random\n\nprint(\"[*] Deleting records in-place\")\n\npath = \"/tmp/test1.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nmode = 0o644  # means 0644\n\ndbm = mdbm.open(path, flags, mode)\n\nfor i in range(0, 10):\n\n    k = str(random.randrange(0, 65534))\n\n    rv = dbm.delete(k)\n    if not rv:\n        print(\"[-] failed to delete an record, key=%s\" % k)\n\n    v = dbm.fetch(k)\n    if v:\n        print(\"[-] failed to delete an record, key=%s, val=%s\" % (k,v))\n        break\n\nprint(\"[*] count of records : %d\" % dbm.count_records())\n\ndbm.close()\n\nprint(\"done\")\n```\n\n### Iterating over all records\n\n```python\nimport mdbm\nimport random\n\nprint(\"[*] Iterating over all records\")\n\npath = \"/tmp/test1.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nmode = 0o644  # means 0644\n\ndbm = mdbm.open(path, flags, mode)\n\nprint(\"|-------|-------|\")\nprint(\"|  key  |  val  |\")\nprint(\"|-------|-------|\")\n\nkv = dbm.first()\n\nprint(\"|%07s|%07s|\" % kv)\n\nwhile kv:\n\n    print(\"|%07s|%07s|\" % kv)\n\n    kv = dbm.next()\n\nprint(\"|-------|-------|\")\nprint(\"[*] count of records : %d\" % dbm.count_records())\n\ndbm.close()\n\nprint(\"done\")\n```\n\n### Iterating over all keys\n\n```python\nimport mdbm\nimport random\n\nprint(\"[*] Iterating over all records\")\n\npath = \"/tmp/test1.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nmode = 0o644  # means 0644\n\ndbm = mdbm.open(path, flags, mode)\n\nprint(\"|-------|\")\nprint(\"|  key  |\")\nprint(\"|-------|\")\n\nk = dbm.firstkey()\n\nprint(\"|%07s|\" % k)\n\nwhile k:\n\n    print(\"|%07s|\" % k)\n\n    k = dbm.nextkey()\n\nprint(\"|-------|\")\nprint(\"[*] count of records : %d\" % dbm.count_records())\n\ndbm.close()\n\nprint(\"done\")\n```\n\n### Iteration over all value by key\n\n```python\nimport mdbm\nimport random\n\nprint(\"[*] Creating and populating a database\")\n\npath = \"/tmp/test_py_dup.mdbm\"\nflags = mdbm.MDBM_O_RDWR\nflags = flags | mdbm.MDBM_O_CREAT\nflags = flags | mdbm.MDBM_LARGE_OBJECTS\nflags = flags | mdbm.MDBM_ANY_LOCKS\nflags = flags | mdbm.MDBM_O_TRUNC\nmode = 0o644  # means 0644\n\nwith mdbm.open(path, flags, mode) as dbm:\n\n    for k in range(0, 100):\n        key = str(k)\n\n        for i in range(1, 12):\n            val = str(123 * i)\n\n            rv = dbm.store(key, val, mdbm.MDBM_INSERT_DUP)\n            if not rv:\n                print(\"[-] failed to data store to \", path)\n                break\n\nprint(\"[*] Loop through DB, looking at records with the same key.\")\nwith mdbm.open(path, mdbm.MDBM_O_RDONLY, mode) as dbm:\n\n    print(\"[*] count of records : %d\" % dbm.count_records())\n    print(\"|-------|-------|\")\n    print(\"|  key  |  val  |\")\n    print(\"|-------|-------|\")\n\n    k = str(random.randrange(0, 99))\n\n    empty_iter = dbm.init_iter()\n    info = dbm.fetch_dup_r(k, empty_iter)\n    while info:\n\n        print(\"|%07s|%07s|\" % (k, info['val']))\n        info = dbm.fetch_dup_r(k, info['iter'])\n\nprint(\"|-------|-------|\")\n\nprint(\"done\")\n```\n\n## Benchmark\n\nThe following is results of Py-mdbm vs AnyDBM vs SQLite3 vs Kyotocabinet benchmarks for simple data storing and random fetching in them.\n\n- See the [Source Code](https://github.com/torden/py-mdbm/blob/master/test_benchmark.py) for more details\n- See the [Glossary](https://pytest-benchmark.readthedocs.io/en/latest/glossary.html) for read result\n\n### Spec\n\n#### Host\n\n|Type|Spec|\n|---|---|\n|CPU|Inte i-7|\n|RAM|DDR4 32G|\n|HDD|Nvme M.2 SSD|\n\n#### VM\n\n|Type|Spec|\n|---|---|\n|Machine|VM(VirtualBox)|\n|OS|CentOS 7 64bit|\n|CPU|2 vCore|\n|RAM|8G|\n|AnyDBM|Berkeley DB (Hash, version 9, native byte-order) format|\n|Mdbm|893f7a8 on 26 Jul, MDBM V3 format|\n|SQLite|V3|\n|Kyotocabinet|1.2.76, kch|\n\n### Command\n\n```\nCMD_PYTHON=`which python` CMD_PYTEST=`which pytest` make benchmark\n```\n\n### File Size\n\n\n|Count of Records|Type|File Name|Size|\n|---|---|--:|--:|\n|10,000|SQLite3|test_py_benchmark_10000.db|300K|\n||AnyDBM|test_py_benchmark_10000.dbm|348K|\n||Kyotocabinet KCH|test_py_benchmark_10000.kch|6.3M|\n||MDBM|test_py_benchmark_10000.mdbm|260K|\n||MDBM(TSC)|test_py_benchmark_tsc_10000.mdbm|260K|\n|100,000|SQLite3|test_py_benchmark_100000.db|3.3M|\n||AnyDBM|test_py_benchmark_100000.dbm|2.5M|\n||Kyotocabinet KCH|test_py_benchmark_100000.kch|9.1M|\n||MDBM|test_py_benchmark_100000.mdbm|4.0M|\n||MDBM(TSC)|test_py_benchmark_tsc_100000.mdbm|4.0M|\n|1,000,000|SQLite3|test_py_benchmark_1000000.db| 35M|\n||AnyDBM|test_py_benchmark_1000000.dbm| 39M|\n||Kyotocabinet KCH|test_py_benchmark_1000000.kch| 37M|\n||MDBM|test_py_benchmark_1000000.mdbm| 32M|\n||MDBM(TSC)|test_py_benchmark_tsc_1000000.mdbm| 32M|\n\n### 10,000 INSERTs\n\n```\nplatform linux2 -- Python 2.7.14, pytest-3.3.2, py-1.5.2, pluggy-0.6.0\nbenchmark: 3.1.1 (defaults: timer=time.time disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)\nrootdir: /root/PERSONAL/py-mdbm, inifile:\nplugins: benchmark-3.1.1\ncollected 31 items\n\n------------------------------------------------------------------------------------------- benchmark: 5 tests ------------------------------------------------------------------------------------------\nName (time in ms)                          Min                 Max                Mean            StdDev              Median               IQR            Outliers      OPS            Rounds  Iterations\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ntest_mdbm_store_tsc_10000              42.7790 (1.0)       46.4041 (1.0)       44.4735 (1.0)      0.8599 (1.0)       44.7228 (1.01)     1.0532 (1.0)           5;0  22.4853 (1.0)          23           1\ntest_mdbm_store_10000                  43.0260 (1.01)      55.0859 (1.19)      45.1026 (1.01)     2.8206 (3.28)      44.1189 (1.0)      1.9995 (1.90)          3;2  22.1716 (0.99)         23           1\ntest_kyotocabinet_kch_store_10000      64.2769 (1.50)      72.2461 (1.56)      66.6182 (1.50)     2.1470 (2.50)      66.5540 (1.51)     2.4997 (2.37)          6;1  15.0109 (0.67)         16           1\ntest_sqlite3_store_10000               71.1770 (1.66)      89.0980 (1.92)      74.6003 (1.68)     4.5800 (5.33)      73.3149 (1.66)     2.8142 (2.67)          1;1  13.4048 (0.60)         13           1\ntest_anydbm_store_10000               129.4661 (3.03)     132.9770 (2.87)     131.7690 (2.96)     1.3268 (1.54)     132.4065 (3.00)     2.1240 (2.02)          1;0   7.5890 (0.34)          8           1\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n```\n\n### 100,000 INSERTs\n\n```\n------------------------------------------------------------------------------------------------ benchmark: 5 tests -----------------------------------------------------------------------------------------------\nName (time in ms)                             Min                   Max                  Mean             StdDev                Median                IQR            Outliers     OPS            Rounds  Iterations\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ntest_mdbm_store_100000                   432.5280 (1.0)        444.3109 (1.0)        440.1428 (1.0)       5.1283 (1.0)        443.0151 (1.0)       7.8554 (1.46)          1;0  2.2720 (1.0)           5           1\ntest_mdbm_store_tsc_100000               443.6021 (1.03)       457.2010 (1.03)       450.7210 (1.02)      6.5694 (1.28)       453.4068 (1.02)     12.3150 (2.28)          2;0  2.2187 (0.98)          5           1\ntest_kyotocabinet_kch_store_100000       553.1771 (1.28)       572.2950 (1.29)       559.4640 (1.27)      7.3967 (1.44)       557.5171 (1.26)      5.3908 (1.0)           1;1  1.7874 (0.79)          5           1\ntest_sqlite3_store_100000                668.3731 (1.55)       690.7680 (1.55)       676.8432 (1.54)     10.4372 (2.04)       670.3589 (1.51)     17.5762 (3.26)          1;0  1.4774 (0.65)          5           1\ntest_anydbm_store_100000               1,746.3379 (4.04)     1,778.0671 (4.00)     1,759.8858 (4.00)     12.6857 (2.47)     1,761.1270 (3.98)     19.0974 (3.54)          2;0  0.5682 (0.25)          5           1\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n```\n\n### 1,000,000 INSERTs\n\n```\n----------------------------------------------------------------------------------------- benchmark: 5 tests -----------------------------------------------------------------------------------------\nName (time in s)                            Min                Max               Mean            StdDev             Median               IQR            Outliers     OPS            Rounds  Iterations\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ntest_mdbm_store_1000000                  4.4507 (1.0)       4.5549 (1.0)       4.5087 (1.0)      0.0386 (1.41)      4.5170 (1.00)     0.0471 (1.0)           2;0  0.2218 (1.0)           5           1\ntest_mdbm_store_tsc_1000000              4.4964 (1.01)      4.5557 (1.00)      4.5252 (1.00)     0.0275 (1.0)       4.5133 (1.0)      0.0494 (1.05)          3;0  0.2210 (1.00)          5           1\ntest_kyotocabinet_kch_store_1000000      5.5518 (1.25)      7.3104 (1.60)      5.9554 (1.32)     0.7585 (27.62)     5.6386 (1.25)     0.4548 (9.65)          1;1  0.1679 (0.76)          5           1\ntest_sqlite3_store_1000000               6.9506 (1.56)      7.1580 (1.57)      7.0168 (1.56)     0.0811 (2.95)      6.9938 (1.55)     0.0623 (1.32)          1;1  0.1425 (0.64)          5           1\ntest_anydbm_store_1000000               18.8494 (4.24)     19.3685 (4.25)     19.1384 (4.24)     0.1884 (6.86)     19.1481 (4.24)     0.1982 (4.21)          2;0  0.0523 (0.24)          5           1\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n```\n\n\n### 10,000 Random Key SELECTs\n\n```\n----------------------------------------------------------------------------------------------- benchmark: 6 tests -----------------------------------------------------------------------------------------------\nName (time in ms)                                 Min                 Max                Mean             StdDev              Median                IQR            Outliers      OPS            Rounds  Iterations\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ntest_mdbm_random_fetch_10000                  33.6039 (1.0)       37.1680 (1.02)      35.4372 (1.0)       0.8726 (1.63)      35.3181 (1.0)       1.0861 (1.73)          9;0  28.2189 (1.0)          29           1\ntest_mdbm_preload_random_fetch_tsc_10000      34.1651 (1.02)      36.5930 (1.0)       35.5276 (1.00)      0.5728 (1.07)      35.6691 (1.01)      0.6691 (1.06)          8;0  28.1471 (1.00)         29           1\ntest_mdbm_preload_random_fetch_10000          34.8370 (1.04)      37.1509 (1.02)      35.6486 (1.01)      0.5368 (1.0)       35.6290 (1.01)      0.6291 (1.0)           8;1  28.0516 (0.99)         27           1\ntest_kyotocabinet_random_fetch_10000          50.1349 (1.49)     315.4690 (8.62)      66.3761 (1.87)     60.3302 (112.39)    52.3400 (1.48)      1.3785 (2.19)          1;1  15.0657 (0.53)         19           1\ntest_anydbm_random_fetch_10000                98.3920 (2.93)     127.4319 (3.48)     103.2393 (2.91)      8.6436 (16.10)    101.2516 (2.87)      3.1178 (4.96)          1;1   9.6862 (0.34)         10           1\ntest_sqlite3_random_fetch_10000              179.9428 (5.35)     264.3309 (7.22)     198.3913 (5.60)     32.8237 (61.15)    183.5115 (5.20)     14.0412 (22.32)         1;1   5.0405 (0.18)          6           1\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n```\n\n\n### 100,000 Random Key SELECTs\n\n```\n-------------------------------------------------------------------------------------------------- benchmark: 5 tests --------------------------------------------------------------------------------------------------\nName (time in ms)                                    Min                   Max                  Mean            StdDev                Median               IQR            Outliers     OPS            Rounds  Iterations\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ntest_mdbm_preload_random_fetch_tsc_100000       351.3479 (1.0)        362.6180 (1.02)       358.0612 (1.01)     4.9707 (3.89)       360.7321 (1.02)     8.1980 (3.88)          1;0  2.7928 (0.99)          5           1\ntest_mdbm_preload_random_fetch_100000           352.9408 (1.00)       360.9550 (1.01)       356.8196 (1.01)     3.2021 (2.51)       357.4481 (1.01)     5.0185 (2.38)          2;0  2.8025 (0.99)          5           1\ntest_mdbm_random_fetch_100000                   353.4501 (1.01)       356.4832 (1.0)        354.6917 (1.0)      1.2767 (1.0)        354.3482 (1.0)      2.1121 (1.0)           1;0  2.8193 (1.0)           5           1\ntest_kyotocabinet_random_fetch_100000           513.2129 (1.46)       516.0379 (1.45)       514.8367 (1.45)     1.3007 (1.02)       515.3730 (1.45)     2.3472 (1.11)          1;0  1.9424 (0.69)          5           1\ntest_anydbm_random_fetch_100000               1,196.3558 (3.41)     1,217.2129 (3.41)     1,207.2943 (3.40)     7.5601 (5.92)     1,206.6510 (3.41)     8.3598 (3.96)          2;0  0.8283 (0.29)          5           1\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n```\n\n### 1,000,000 Random Key SELECTs\n\n```\n--------------------------------------------------------------------------------------------- benchmark: 5 tests --------------------------------------------------------------------------------------------\nName (time in s)                                   Min                Max               Mean            StdDev             Median               IQR            Outliers     OPS            Rounds  Iterations\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ntest_mdbm_preload_random_fetch_tsc_1000000      3.6708 (1.0)       3.7161 (1.0)       3.7020 (1.0)      0.0194 (1.29)      3.7138 (1.00)     0.0255 (1.71)          1;0  0.2701 (1.0)           5           1\ntest_mdbm_preload_random_fetch_1000000          3.6781 (1.00)      3.7315 (1.00)      3.7045 (1.00)     0.0212 (1.41)      3.7021 (1.0)      0.0336 (2.25)          2;0  0.2699 (1.00)          5           1\ntest_mdbm_random_fetch_1000000                  3.6957 (1.01)      3.7336 (1.00)      3.7079 (1.00)     0.0150 (1.0)       3.7054 (1.00)     0.0149 (1.0)           1;0  0.2697 (1.00)          5           1\ntest_kyotocabinet_random_fetch_1000000          5.2549 (1.43)      5.2865 (1.42)      5.2677 (1.42)     0.0151 (1.01)      5.2599 (1.42)     0.0273 (1.82)          1;0  0.1898 (0.70)          5           1\ntest_anydbm_random_fetch_1000000               12.3323 (3.36)     12.4784 (3.36)     12.4044 (3.35)     0.0586 (3.90)     12.3911 (3.35)     0.0927 (6.20)          2;0  0.0806 (0.30)          5           1\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n```\n\n## Link\n\n- [Yahoo! MDBM](https://github.com/yahoo/mdbm)\n- [MDBM::Concept](http://yahoo.github.io/mdbm/guide/concepts.html)\n- [MDBM::Build](https://github.com/yahoo/mdbm/blob/master/README.build)\n- [MDBM::Document](http://yahoo.github.io/mdbm/)\n- [MDBM::FAQ](http://yahoo.github.io/mdbm/guide/faq.html)\n- [DBM](https://en.wikipedia.org/wiki/Dbm)\n- [MDBM::Macro(const)](http://yahoo.github.io/mdbm/api/mdbm_8h.html)\n- [MDBM Packages](https://github.com/torden/mdbm)\n- [Go-mdbm](https://github.com/torden/go-mdbm)\n- [PHP-mdbm](https://github.com/torden/php-mdbm)\n- [Py-mdbm in Pypi](https://pypi.python.org/pypi/py-mdbm)\n\n---\nPlease feel free. I hope it is helpful for you\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorden%2Fpy-mdbm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorden%2Fpy-mdbm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorden%2Fpy-mdbm/lists"}