{ "info": { "author": "Patrick Schneeweis", "author_email": "psbleep@protonmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Software Development" ], "description": "[![Build Status](https://travis-ci.org/psbleep/dictwrap.svg?branch=master)](https://travis-ci.org/psbleep/dictwrap)[![PyPI](https://img.shields.io/badge/pypi-0.0.1-blue.svg)](https://pypi.org/project/dictwrap/)\n# dictwrap\n\nPython library for wrapping persistent data storage in a dictionary interface.\n\n## json\\_dict\nExample usage:\n\n from dictwrap import json_dict\n\n config = json_dict(\"config_file.json\")\n config[\"hello\"] = \"world\"\n\nThis will establish a dictionary wrapper around the contents of `config_file.json`. Changes to the dictionary will be written to the JSON file automatically.\n\nTo override automatic updates to the JSON file and save changes manually:\n\n from dictwrap import json_dict\n\n config = json_dict(\"config_file.json\", autosave=False)\n\n config[\"hello\"] = \"world\" # This change is not written to the file yet.\n config.save() # The change is now written to the file.\n\n\n## sql\\_row\nExample usage:\n\n from dictwrap import sql_row\n\n row = sql_row(\"db_driver://user:pass@host/db_name\", table=\"example\", lookup_field=\"id\", lookup_value=1)\n\nBy default you will not set save changes to the ditionary until the `save` method is called:\n\n row[\"foo\"] = \"bar\" # Not saved to the database yet.\n row.save() # Database is now updated.\n\nYou can override this using the `autosave` attribute when creating the row:\n\n row = sql_row(\"sqlite://\", table=\"example\", lookup_field=\"id\", lookup_id=1, autosave=True)\n row[\"foo\"] = \"bar\" # Database is automatically updated.\n\nTo update data for the dictionary from the database, call the `refresh` method:\n\n row.refresh()\n\nBy using the `autorefresh` attribute when creating the row, data will be updated from the database whenever a key value is looked up on the dictionary:\n\n row = sql_row(\"sqlite://\", table=\"example\", lookup_field=\"id\", lookup_id=1, autorefresh=True)\n print(row[\"foo\"]) # Accessing the key now calls the database to update any data that has been changed.\n\nIf you only need certain fields from the database to be included in the dictionary, pass a list of field names when creating the row:\n\n row = sql_row(\"sqlite://\", table=\"example\", lookup_field=\"id\", lookup_id=1, fields=[\"foo\", \"bar\"])\n\nTo create a new row in the database, do not provide a `lookup_field` or `lookup_id` attribute and pass a dictionary into the `data` attribute:\n\n row = sql_row(\"sqlite://\", table=\"example\", update={\"foo\": \"bar\"})\n # Creates a row in the `example` table with the `foo` field set to \"bar\".\n\nYou will need to provide valid data for all fields required by the database for this work.\n\n## csv\\_row\nExample usage:\n\n from dictwrap import csv_row\n\n row = csv_row(\"file_path.csv\", row_id=0)\n\nThis will create a dictionary that reads and writes to the first row of the CSV file provided. (Remember what index number arrays start at.)\n\nYou can identify which row in the CSV file to wrap in the dictionary either by row number, or by passing a dictionary with a key-value pairing for the row you want to find. For example, if the CSV file has a field called `Author` you would be able to lookup the row for `Ursula LeGuin` like this:\n\n row = csv_row(\"authors.csv\", row_id={\"Author\": \"Ursula LeGuin\"})\n\nBy default, fieldnames will be read from the first row of the CSV file. If the file lacks such a header row, fieldnames can be passed explicitly as a list:\n\n row = csv_row(\"authors.csv\", row_id=1, fieldnames=[\"ID\", \"Name\", \"Rating\"])\n\n\n## api\\_record\nExample usage:\n\n from dictwrap import api_record\n\n record = api_record(\"httsp://fake.org/api/record/1/\", auth=(\"user\", \"pass\"))\n\nThis will call the GET request method on the URL endpoint provided, and provide the username/password provided in the tuple for authentication. Saving will call the PATCH method on the same method. Later I intend to create more flexibility for this type.\n\n## Contact\nThis project is obviously very early in development. I started it to create an easily-installable package with some dictionary wrappers I found myself frequently rewriting. I've been adding more types for fun.\n\nContact me at psbleep@protonmail.com or open an issue/pull request on Github with questions, suggestions, or improvements.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/psbleep/dictwrap", "keywords": "json mysql sql dict dictionary", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "dictwrap", "package_url": "https://pypi.org/project/dictwrap/", "platform": "", "project_url": "https://pypi.org/project/dictwrap/", "project_urls": { "Homepage": "https://github.com/psbleep/dictwrap" }, "release_url": "https://pypi.org/project/dictwrap/0.0.2/", "requires_dist": [ "SQLAlchemy (>=1.2.12)", "requests (>=2.19.1)" ], "requires_python": ">=3", "summary": "Library for wrapping data storage in a dict interface.", "version": "0.0.2" }, "last_serial": 4357721, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "40016b52d2fb527690e38748d6691ad7", "sha256": "f63be6d8fea5d7832a2dea7e99113fc764b2f7d141ec41e82963db9feab9a3fa" }, "downloads": -1, "filename": "dictwrap-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "40016b52d2fb527690e38748d6691ad7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 15016, "upload_time": "2018-10-03T23:00:31", "url": "https://files.pythonhosted.org/packages/90/ce/b1bb68ae7132cf30a4a60643028c8e1690c633c3685fda451263ab1d39e3/dictwrap-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0525d10db80bbef9f3429be070a17cd8", "sha256": "44f73d0afe78999ad293fa8527896309a8d70d2382dc7c8493ac544ec669e3f7" }, "downloads": -1, "filename": "dictwrap-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0525d10db80bbef9f3429be070a17cd8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 2318, "upload_time": "2018-10-03T23:00:32", "url": "https://files.pythonhosted.org/packages/d9/b5/050f97ee48650f1ef90bbb2c3ffbf05667054a74e81727b01e726fcf8454/dictwrap-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "85035005636af3dde4a1a62e0b4d6604", "sha256": "df4debd9f55bcc7f3537d5bd0934fb02a212aa71ffda91f7b5deb62995839203" }, "downloads": -1, "filename": "dictwrap-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "85035005636af3dde4a1a62e0b4d6604", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 17395, "upload_time": "2018-10-09T21:56:26", "url": "https://files.pythonhosted.org/packages/20/36/76d154bf20d8269a4478b7bd6ee8de06898a41225c1f1c3f9921f0ae6af6/dictwrap-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6015c3a6ed9f5887863ccfe2b2621d7a", "sha256": "8c2194e31288e9fa7ef9a65be9a4cdeab4824e3dc039b5b9c0cae36a3d0ba915" }, "downloads": -1, "filename": "dictwrap-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6015c3a6ed9f5887863ccfe2b2621d7a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 4870, "upload_time": "2018-10-09T21:56:28", "url": "https://files.pythonhosted.org/packages/1d/5e/f25f3ff3ff721b406fc65a40689a8419c112254a6bd2bb38e603d78135ac/dictwrap-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "85035005636af3dde4a1a62e0b4d6604", "sha256": "df4debd9f55bcc7f3537d5bd0934fb02a212aa71ffda91f7b5deb62995839203" }, "downloads": -1, "filename": "dictwrap-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "85035005636af3dde4a1a62e0b4d6604", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 17395, "upload_time": "2018-10-09T21:56:26", "url": "https://files.pythonhosted.org/packages/20/36/76d154bf20d8269a4478b7bd6ee8de06898a41225c1f1c3f9921f0ae6af6/dictwrap-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6015c3a6ed9f5887863ccfe2b2621d7a", "sha256": "8c2194e31288e9fa7ef9a65be9a4cdeab4824e3dc039b5b9c0cae36a3d0ba915" }, "downloads": -1, "filename": "dictwrap-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6015c3a6ed9f5887863ccfe2b2621d7a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 4870, "upload_time": "2018-10-09T21:56:28", "url": "https://files.pythonhosted.org/packages/1d/5e/f25f3ff3ff721b406fc65a40689a8419c112254a6bd2bb38e603d78135ac/dictwrap-0.0.2.tar.gz" } ] }