jsonLookup


NamejsonLookup JSON
Version 0.9.0 PyPI version JSON
download
home_pagehttps://github.com/mkalioby/jsonLookup
SummarySearch MySQL JSON fields in Django
upload_time2020-10-27 11:20:10
maintainer
docs_urlNone
authorMohamed El-Kalioby
requires_python
license
keywords django django mysql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jsonLookup
Searching in MySQL JSON field in Django

# Challenge

MySQL has introduced JSON fields in MySQL Server 5.7, Currently it works well with [jsonfield](https://github.com/bradjasper/django-jsonfield) for Data Saving and retrieval. The problem that Searching can only be done through LIKE operator which isn't convinent for all function.

# Objective

Creating a new custom lookup operator "has" for Django that will support JSON Search in MySQL.

# Installation

### Install the Package
```sh
$ pip install jsonLookup
```

### Register to JSONFields

```python
from jsonLookup import hasLookup,jcontainsLookup
JSONField.register_lookup(hasLookup)
JSONField.register_lookup(jcontainsLookup)
```

### Write your JSON queries

```python
# Create test objects
User.objects.create(name="Ahmed",properties={"city":"Giza","Address":{"district":"Ahram","Code":11263}})
User.objects.create(name="Mohamed",properties={"city":"Cairo","Address":{"district":"Helipolis","Code":11351}})
# Run first query
q = User.objects.filter(properties__has="$.city=Giza")
print q[0].name
"Ahmed"
# Run Second query
q= User.objects.filter(properties__has="$.Address.Code=11351")
print q[0].name
"Mohamed"
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mkalioby/jsonLookup",
    "name": "jsonLookup",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,django,mysql",
    "author": "Mohamed El-Kalioby",
    "author_email": "mkalioby@mkalioby.com",
    "download_url": "https://files.pythonhosted.org/packages/eb/38/4c23a9803fd4726d25e708f76a3d0164573d21d2ec5ccbd8ec8fcbec50e4/jsonLookup-0.9.0.tar.gz",
    "platform": "",
    "description": "# jsonLookup\nSearching in MySQL JSON field in Django\n\n# Challenge\n\nMySQL has introduced JSON fields in MySQL Server 5.7, Currently it works well with [jsonfield](https://github.com/bradjasper/django-jsonfield) for Data Saving and retrieval. The problem that Searching can only be done through LIKE operator which isn't convinent for all function.\n\n# Objective\n\nCreating a new custom lookup operator \"has\" for Django that will support JSON Search in MySQL.\n\n# Installation\n\n### Install the Package\n```sh\n$ pip install jsonLookup\n```\n\n### Register to JSONFields\n\n```python\nfrom jsonLookup import hasLookup,jcontainsLookup\nJSONField.register_lookup(hasLookup)\nJSONField.register_lookup(jcontainsLookup)\n```\n\n### Write your JSON queries\n\n```python\n# Create test objects\nUser.objects.create(name=\"Ahmed\",properties={\"city\":\"Giza\",\"Address\":{\"district\":\"Ahram\",\"Code\":11263}})\nUser.objects.create(name=\"Mohamed\",properties={\"city\":\"Cairo\",\"Address\":{\"district\":\"Helipolis\",\"Code\":11351}})\n# Run first query\nq = User.objects.filter(properties__has=\"$.city=Giza\")\nprint q[0].name\n\"Ahmed\"\n# Run Second query\nq= User.objects.filter(properties__has=\"$.Address.Code=11351\")\nprint q[0].name\n\"Mohamed\"\n```",
    "bugtrack_url": null,
    "license": "",
    "summary": "Search MySQL JSON fields in Django",
    "version": "0.9.0",
    "split_keywords": [
        "django",
        "django",
        "mysql"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "ac3d1df00da31f10a236b5b8e8c8529e",
                "sha256": "95bb1cd51e04e21c1b5a70ec5faa597b8435cb94da868fbbd5d1550fc7c88432"
            },
            "downloads": -1,
            "filename": "jsonLookup-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ac3d1df00da31f10a236b5b8e8c8529e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3005,
            "upload_time": "2020-10-27T11:20:10",
            "upload_time_iso_8601": "2020-10-27T11:20:10.278865Z",
            "url": "https://files.pythonhosted.org/packages/eb/38/4c23a9803fd4726d25e708f76a3d0164573d21d2ec5ccbd8ec8fcbec50e4/jsonLookup-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-27 11:20:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "mkalioby",
    "github_project": "jsonLookup",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "jsonlookup"
}
        
Elapsed time: 0.05393s