{ "info": { "author": "Michael Lamb", "author_email": "mr.lamby@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "dq.py - Python DataQuery\n=========================\nProvides the ability to query a data source made up of any combination\nof lists and dicts.\n\nTo use from within Python:\n```python\n>>> from dq import query\n>>> dq.query('[0].name', [{'name': 'michael'}, {'name': 'jane'}])\n'michael' \n\n>>> dq.query('..name', [{'name': 'michael'}, {'name': 'jane'}])\n['michael', 'jane']\n```\nInstallation\n------------\nTo install dq:\n```\npip install dq\n```\ndq does not depend on any non-standard libraries\n\nQuery Language\n--------------\nThe query language is a much simplified version of [json path][1]. The subset\nis selected to allow for simple structural querying of data - no filters or \nexpressions. This keeps the parser nice and simple, and since its a Python\nlibrary you have the full power of Python to perform complex filters.\n\nThe query language supports the following path syntax:\n```\n.key - Returns the given key from the dict\n..key - Returns the given key from any descendant dictionary \n[index] - Returns an item from a list at the specified index\n[*] - Returns all items in a list\n[start:stop:step] - Performs a python slice operation on a list\n```\n\nQuery Examples\n--------------\nThese syntax items can be combined to build complex queries.\n```python\n>>> from dq import query\n>>> d = {}\n>>> d['one'] = 1\n>>> d['two'] = [1,2,3,4,5,6,7,8,9,10]\n>>> d['three'] = [{'name': 'john'}, {'name': 'mary'}, {'one': 'guy'}]\n\n>>> query('.one', d)\n1\n\n>>> query('.two', d)\n[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\n>>> query('.two[1]', d)\n2\n\n>>> query('.two[*]', d)\n[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\n>>> query('.two[2:-2]', d)\n[3, 4, 5, 6, 7, 8]\n\n>>> query('.two[1:6:2]', d)\n[2, 4, 6]\n\n>>> query('.three[1].name', d)\n'mary'\n\n>>> query('.three[*].name', d)\n['john', 'mary']\n\n>>> query('..name', d)\n['john', 'mary']\n\n>>> query('..one', d)\n[1, 'guy']\n```\n\nCompiled Queries\n----------------\nWhen using the same query string repeatedly a CompiledQuery can be constructed\nto prevent parsing the query string multiple times:\n```python\n>>> from dq import compiled\n>>> query = compiled('[1]')\n>>> query([1,2,3,4])\n2\n>>> query([5,6,7,8])\n6\n```\n\nThanks\n-------\nThis library is based on the ideas and code from [python-jsonpath-rw][2].\n\nCopyright\n---------\nCopyright (c) 2013 Michael Lamb. See LICENSE.txt for details.\n\n[1]: http://goessner.net/articles/JsonPath/ \"Json Path\"\n[2]: https://github.com/kennknowles/python-jsonpath-rw \"python-jsonpath-rw\"", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mlamby/dq", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "dq", "package_url": "https://pypi.org/project/dq/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dq/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/mlamby/dq" }, "release_url": "https://pypi.org/project/dq/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "Python Simple Data Query", "version": "0.1.2" }, "last_serial": 791389, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "d075238cb5613aa2cf22f479ae972018", "sha256": "0a375f1385af15257660ef23641e9de706dfd227d5b713af1497cb2fe0c64888" }, "downloads": -1, "filename": "dq-0.1.2.tar.gz", "has_sig": false, "md5_digest": "d075238cb5613aa2cf22f479ae972018", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4700, "upload_time": "2013-04-21T06:03:25", "url": "https://files.pythonhosted.org/packages/c3/b8/caec444f580ef5d0eaf4b78fcbb73d69b33e145ca91dc1eb3520fead9953/dq-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d075238cb5613aa2cf22f479ae972018", "sha256": "0a375f1385af15257660ef23641e9de706dfd227d5b713af1497cb2fe0c64888" }, "downloads": -1, "filename": "dq-0.1.2.tar.gz", "has_sig": false, "md5_digest": "d075238cb5613aa2cf22f479ae972018", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4700, "upload_time": "2013-04-21T06:03:25", "url": "https://files.pythonhosted.org/packages/c3/b8/caec444f580ef5d0eaf4b78fcbb73d69b33e145ca91dc1eb3520fead9953/dq-0.1.2.tar.gz" } ] }