{"id":17090988,"url":"https://github.com/ipazc/pymdict","last_synced_at":"2025-04-12T22:30:03.501Z","repository":{"id":62581643,"uuid":"119725962","full_name":"ipazc/pymdict","owner":"ipazc","description":"mongodict is a python's dictionary supported by a mongo db.","archived":false,"fork":false,"pushed_at":"2024-04-08T16:09:16.000Z","size":80,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T16:38:43.029Z","etag":null,"topics":["bulk","dict","dictionary","fork","mongo","mongodb","python","query","versioning"],"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/ipazc.png","metadata":{"files":{"readme":"README.rst","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-31T18:25:24.000Z","updated_at":"2025-03-24T01:54:48.000Z","dependencies_parsed_at":"2024-08-23T01:16:35.219Z","dependency_job_id":"2033fe09-5b52-4e18-a3ff-9b1c43de96d9","html_url":"https://github.com/ipazc/pymdict","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":0.4736842105263158,"last_synced_commit":"474915d181b83a92b093f32f3ed59fbcce1cc356"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipazc%2Fpymdict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipazc%2Fpymdict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipazc%2Fpymdict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipazc%2Fpymdict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipazc","download_url":"https://codeload.github.com/ipazc/pymdict/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248639638,"owners_count":21137881,"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":["bulk","dict","dictionary","fork","mongo","mongodb","python","query","versioning"],"created_at":"2024-10-14T13:57:15.665Z","updated_at":"2025-04-12T22:30:03.456Z","avatar_url":"https://github.com/ipazc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"PyMDict\n#######\n\n.. image:: https://badge.fury.io/py/pymdict.svg\n    :target: https://badge.fury.io/py/pymdict\n.. image:: https://travis-ci.org/ipazc/pymdict.svg?branch=master\n    :target: https://travis-ci.org/ipazc/pymdict\n.. image:: https://coveralls.io/repos/github/ipazc/pymdict/badge.svg?branch=master\n    :target: https://coveralls.io/github/ipazc/pymdict?branch=master\n\n\nAdvanced Python Mongo Dict.\nA Python dictionary based on a MongoDB. It allows to treat a collection as a dictionary in Python, with extensive capabilities, like allowing basic queries, bulk operations and versioning (forks).\n\nINSTALLATION\n############\n\nCurrently it is only supported Python3.4 onwards. It can be installed through pip:\n\n.. code:: bash\n\n    $ pip3 install pymdict\n\n\nUSAGE\n#####\n\nIn order to run, a MongoDB server is required.\n\nA Mongo-based dictionary can be instantiated as follows:\n\n.. code:: python\n\n    \u003e\u003e\u003e from pymdict.mongo_dict import MongoDict\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e m = MongoDict(\"custom_id\", mongo_host=\"localhost\", mongo_port=27017)\n\n\nOnce `m` is instantiated, it can be used as a normal dictionary.\n\n.. code:: python\n\n    \u003e\u003e\u003e m[\"key\"] = \"value\"\n    \u003e\u003e\u003e m[44] = \"value2\"\n    \u003e\u003e\u003e m[\"key2\"] = \"value3\"\n    \u003e\u003e\u003e m[\"number\"] = 44\n\n    \u003e\u003e\u003e print(list(m.keys()))\n    [\"key\", 44, \"key2, \"number\"]\n\n    \u003e\u003e\u003e for key, value in m.items():\n    ...     print(\"{}: {}\".format(key, value))\n    key: value\n    44: value2\n    key2: value3\n    number: 44\n\n\nIn addition, there are advanced functionalities like queries:\n\n.. code:: python\n\n    \u003e\u003e\u003e for key, value, _ in m('key % ey'):\n    ...     print(\"{}: {}\".format(key, value))\n    key: value\n    key2: value3\n\n    \u003e\u003e\u003e for key, value, _ in m('key % ey or value = 44'):\n    ...     print(\"{}: {}\".format(key, value))\n    key: value\n    key2: value3\n    number: 44\n\nQueries also support to query with sub-dict elements:\n\n.. code:: python\n\n    \u003e\u003e\u003e m[\"first\"] = {\"example\": 44}\n    \u003e\u003e\u003e m[\"second\"] = {\"example\": 45}\n    \u003e\u003e\u003e m[\"third\"] = {\"example\": 46}\n\n    \u003e\u003e\u003e for key, value, _ in m('value.example \u003e 44 and value.example \u003c 46'):\n    ...     print(\"{}: {}\".format(key, value))\n    second: 45\n\n(TODO: Check the wiki page for more information about the query syntax)\n\nNote that all the stores and removals are stored within a MongoDB. This means for each addition,edit and removal there is at least one connection to the MongoDB backend. In order to optimize it, a bulk operation can be used to wrap such amount of operations in a single connection:\n\n.. code:: python\n\n    \u003e\u003e\u003e with m.bulk(buffer_size=100) as m:\n    ...     for x in range(2000):\n    ...         m[\"key{}\".format(x)] = {\"example\": x}\n\nAlso, a mongo dict can be forked without the need to copy its content. This is specially useful if the target dict is extremely big and a copy is wanted. Note that a fork is an immediate process, and it allows to override or remove elements without modifying an original dictionary. It is achieved by applying a versioning technique with the dictionaries and it is still in an experimental state.\n\n(TODO: More information about forking and versioning in the wiki page)\n\n.. code:: python\n\n    \u003e\u003e\u003e m['foo'] = \"bar\"\n    \u003e\u003e\u003e fork = m.fork()\n    \u003e\u003e\u003e print(fork['foo'])\n    bar\n    \u003e\u003e\u003e fork['foo'] = \"foo\"\n    \u003e\u003e\u003e print(fork['foo'], m['foo'])\n    foo bar\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipazc%2Fpymdict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipazc%2Fpymdict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipazc%2Fpymdict/lists"}