{ "info": { "author": "Joe Cross", "author_email": "joe.mcross@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "jsonquery\n========================================================\n\n.. image:: https://travis-ci.org/numberoverzero/jsonquery.svg?branch=master\n :target: https://travis-ci.org/numberoverzero/jsonquery\n.. image:: https://coveralls.io/repos/numberoverzero/jsonquery/badge.png?branch=master\n :target: https://coveralls.io/r/numberoverzero/jsonquery?branch=master\n\nBasic json -> sqlalchemy query builder\n\n\nInstallation\n========================================================\n\n::\n\n pip install jsonquery\n\nBasic Usage\n========================================================\n\nLet's define a model and get an engine set up::\n\n from sqlalchemy import Column, Integer, String, create_engine\n from sqlalchemy.orm import sessionmaker\n from sqlalchemy.ext.declarative import declarative_base\n\n Base = declarative_base()\n\n class User(Base):\n __tablename__ = 'users'\n id = Column(Integer, primary_key=True)\n name = Column(String)\n email = Column(String)\n age = Column(Integer)\n height = Column(Integer)\n engine = create_engine(\"sqlite://\", echo=True)\n Base.metadata.create_all(engine)\n model = User\n session = sessionmaker(bind=engine)()\n\nWe want to get all users whose name starts with 'Pat' and are\nat least 21::\n\n from jsonquery import jsonquery\n\n json = {\n \"operator\": \"and\",\n \"value\": [\n {\n \"operator\": \">=\",\n \"column\": \"age\",\n \"value\": 21\n },\n {\n \"operator\": \"ilike\",\n \"column\": \"name\",\n \"value\": \"pat%\"\n }\n ]\n }\n\n query = jsonquery(session, User, json)\n users = query.all()\n\nSupported Data Types\n========================================================\n\njsonquery doesn't care about column type. Instead, it uses a whitelist of operators,\nwhere keys are strings (the same that would be passed in the \"operator\" field of a node)\nand the values are functions that take a column object and a value and return a\nsqlalchemy criterion. Here are some examples::\n\n def greater_than(column, value):\n return column > value\n register_operator(\">\", greater_than)\n\n def like(column, value):\n like_func = getattr(column, 'like')\n return like_func(value)\n register_operator(\"like\", like)\n\nBy default, the following are registered::\n\n >, >=, ==, !=, <=, <\n like, ilike, in_\n\nUse ``unregister_operator(opstring)`` to remove an operator.\n\nFuture Goals\n========================================================\n\nThere are a few features I want to add, but these are mostly convenience and aren't necessary to\nthe core application, which I believe is satisfied.\n\nCompressed and/or format\n--------------------------------------------------------\n\nReduce repetitive column and operator specification when possible by allowing non-scalar values\nfor column operators. By flipping the nesting restriction on logical operators, we can omit\nfields specified at the column level. This is especially prominent in string matching,\nwhen the column and operator are the same, but we want to compare against 3+ values.\n\nCurrently::\n\n {\n \"operator\": \"or\",\n \"value\": [\n {\n \"column\": \"age\",\n \"operator\": \"<=\",\n \"value\": 16\n },\n {\n \"column\": \"age\",\n \"operator\": \">=\",\n \"value\": 21\n },\n {\n \"column\": \"age\",\n \"operator\": \"==\",\n \"value\": 18\n }\n ]\n }\n\nWith compressed logical operators::\n\n {\n \"column\": \"age\"\n \"value\": {\n \"operator\": \"or\",\n \"value\": [\n {\n \"operator\": \"<=\",\n \"value\": 16\n },\n {\n \"operator\": \">=\",\n \"value\": 21\n },\n {\n \"operator\": \"==\",\n \"value\": 18\n }\n ]\n }\n }\n\nOr, when the operator is the same::\n\n {\n \"column\": \"name\"\n \"operator\": \"like\"\n \"value\": {\n \"operator\": \"or\",\n \"value\": [\n \"Bill\",\n \"Mary\",\n \"Steve\"\n ]\n }\n }\n\nContributors\n========================================================\n\n* duesenfranz_ - Python 3 compatibility\n* svisser_ - Python 3 compatibility\n\n.. _duesenfranz: https://github.com/duesenfranz\n.. _svisser: https://github.com/svisser\n\n\n1.0.0\n-----\n* First public release", "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/numberoverzero/jsonquery", "keywords": "json sqlalchemy sql orm", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "jsonquery", "package_url": "https://pypi.org/project/jsonquery/", "platform": "any", "project_url": "https://pypi.org/project/jsonquery/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/numberoverzero/jsonquery" }, "release_url": "https://pypi.org/project/jsonquery/1.0.2/", "requires_dist": null, "requires_python": null, "summary": "Basic json -> sqlalchemy query builder", "version": "1.0.2" }, "last_serial": 1548700, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "b4e3a44e0d2a2b38f57aad9db245a33f", "sha256": "9cba7cd98747d76023bb1e9e5d2988397c411b11e2737f27b51c791df5859f80" }, "downloads": -1, "filename": "jsonquery-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b4e3a44e0d2a2b38f57aad9db245a33f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5455, "upload_time": "2014-10-08T05:29:13", "url": "https://files.pythonhosted.org/packages/9b/05/3a263ce1f3d44eac779326066aca00cea7208e23f7276f91d80a82312650/jsonquery-0.1.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "0b01e062067d64265c9aa57985a49b2f", "sha256": "39d0f3bce162a087b6af621acecd82a6f082010103e579f215997519df139883" }, "downloads": -1, "filename": "jsonquery-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0b01e062067d64265c9aa57985a49b2f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5544, "upload_time": "2013-08-16T01:54:43", "url": "https://files.pythonhosted.org/packages/b4/9d/24ab14e619076319e6b8e55bc17e0fcee2120418d9cc41bbc76bfbb57e04/jsonquery-0.2.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "c98da5ae20b4ca4ea58f3e3fdf1a5635", "sha256": "a384be7965ac77c2f78aab46720bc13cc5653fc61e58bce2060d6bcf58f557b4" }, "downloads": -1, "filename": "jsonquery-1.0.0.tar.gz", "has_sig": false, "md5_digest": "c98da5ae20b4ca4ea58f3e3fdf1a5635", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5335, "upload_time": "2014-10-08T05:31:49", "url": "https://files.pythonhosted.org/packages/1c/96/d57935ecef31a9ce937d3a8864a08f4561c75bd5e3d2fca129d477e52d03/jsonquery-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "6cd17aea143e52040d0edb94e9e44b2a", "sha256": "1e80ad1814d2aa066d0ba4702be5c30a1d3c3d2e47c1413cfed45f6f248feada" }, "downloads": -1, "filename": "jsonquery-1.0.1.tar.gz", "has_sig": false, "md5_digest": "6cd17aea143e52040d0edb94e9e44b2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5393, "upload_time": "2015-01-17T17:52:52", "url": "https://files.pythonhosted.org/packages/ce/fd/e8d0639aaa2f44559ba91fa846de277857de5dccf7c0fd0c895f8ff26d31/jsonquery-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "ce95051f7216fc56988ef7aa0fe8ce65", "sha256": "119717dcd14d3720c8378b32afd77d78ad423c6e80ae70bd7e8b85b2b863ffb7" }, "downloads": -1, "filename": "jsonquery-1.0.2.tar.gz", "has_sig": false, "md5_digest": "ce95051f7216fc56988ef7aa0fe8ce65", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5391, "upload_time": "2015-05-15T18:53:54", "url": "https://files.pythonhosted.org/packages/f8/48/04c0806cce45c738cca20876fa733ca96b6179a9e5453c44f90836e72f9e/jsonquery-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ce95051f7216fc56988ef7aa0fe8ce65", "sha256": "119717dcd14d3720c8378b32afd77d78ad423c6e80ae70bd7e8b85b2b863ffb7" }, "downloads": -1, "filename": "jsonquery-1.0.2.tar.gz", "has_sig": false, "md5_digest": "ce95051f7216fc56988ef7aa0fe8ce65", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5391, "upload_time": "2015-05-15T18:53:54", "url": "https://files.pythonhosted.org/packages/f8/48/04c0806cce45c738cca20876fa733ca96b6179a9e5453c44f90836e72f9e/jsonquery-1.0.2.tar.gz" } ] }