{"id":19090173,"url":"https://github.com/destrangis/indexed","last_synced_at":"2026-06-20T13:32:13.250Z","repository":{"id":137496111,"uuid":"214284068","full_name":"destrangis/indexed","owner":"destrangis","description":"Indexed file class xdbm style","archived":false,"fork":false,"pushed_at":"2019-10-10T21:04:10.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-12T13:32:23.305Z","etag":null,"topics":["example-code","indexed-db","python-module","python3"],"latest_commit_sha":null,"homepage":null,"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/destrangis.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":"2019-10-10T20:56:08.000Z","updated_at":"2019-10-10T22:40:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"75bfae8b-3e6d-4858-9fbd-8d4ebff1bb93","html_url":"https://github.com/destrangis/indexed","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/destrangis/indexed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/destrangis%2Findexed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/destrangis%2Findexed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/destrangis%2Findexed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/destrangis%2Findexed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/destrangis","download_url":"https://codeload.github.com/destrangis/indexed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/destrangis%2Findexed/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34572424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"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":["example-code","indexed-db","python-module","python3"],"created_at":"2024-11-09T03:02:45.701Z","updated_at":"2026-06-20T13:32:13.231Z","avatar_url":"https://github.com/destrangis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### IndexedFile\n\nThis is a simple implementation of Indexed files similar, but not identical, to dbm/gdbm/ndbm.\n\n#### Usage\nInstantiation:\n\n~~~python\nfrom indexed import IndexedFile\n\ndb = IndexedFile(\"database.db\", \"c\")\n~~~\n\nStore some data. Keys must be hashable objects, and the content can only be bytes:\n\n~~~python\ndb[(\"IDENT\", 405)] = b\"this is info to be stored\"\ndb[35] = json.dumps({ \"name\": \"Phil\", \n                      \"address\": \"35, Barnacle st.\", \n                      \"date_of_birth\": \"1982/11/24\"}).encode()\n~~~\n\nRetrieve data:\n\n~~~python\nprint(db[(\"IDENT\", 405)])  # prints b'this is info to be stored'\n~~~\n\nBad keys throw `KeyError` exception:\n\n~~~python\ndb[\"badkey\"]   # KeyError: 'badkey'\n~~~\n\nthe `.keys()`, `.values()` and `.items()` methods behave like in dictionaries, and the objects are iterable. Iterating over an `IndexedFile` gives the keys in any order:\n\n~~~python\nfor key in db:\n   print(key, end=\" \")  # prints 35 (\"IDENT\", 405)\n~~~\n\nUsing `.close()` method closes the object and it cannot be used further. To use after `.close()`, a new instance should be created.\n\n~~~python\ndb.close()\n~~~\n\nThe objects are context managers:\n\n~~~python\nwith IndexedFile(\"database.db\", \"r\") as db:\n\tprint(db[35])\n~~~\n\n#### Reference\n**IndexedFile(name, mode='r', recordsize=DEFAULT_RECORD_SIZE, num_recs_hint=DEFAULT_NUM_RECORDS)**\n\nCreate a new IndexedFile object, where `name` is the filename to store it to, `mode` is either 'c' which creates or resets a new file, or 'r' which opens an existing file.\n\n`recordsize` is the size of each record. Data items can be bigger than the recordsize, in which case a suitable number of records will be allocated to contain the object.\n\n`num_recs_hint` is the number of free records initially allocated. When more records are needed than are available the file will be resized to double its size.\n\nrecordsize and num_recs_hint, if specified, are ignored on `mode` 'r'.\n\n**IndexedFile.close()**\n\nCloses access to the IndexedFile. The file cannot be re-opened. In order to access the file after `.close()` a new instance should be created with `mode` 'r'\n\n**IndexedFile.keys()**\n\nReturns an iterable that gives the keys in sequence\n\n**IndexedFile.values()**\n\nReturns an iterable that gives the values in sequence\n\n**IndexedFile.items()**\n\nReturns and iterable that gives tuples of the form _(key, value)_\n\n#### License\nThis software is released under the **MIT License**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdestrangis%2Findexed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdestrangis%2Findexed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdestrangis%2Findexed/lists"}