Skip to main content

A JSON field for Oracle backends.

Project description


# Oracle Json Field
django_json_field is a reusable Django field that allows you to store validated JSON your database and your model
It is heavily inspired by the Postgres Json Field and this generic json field:
https://raw.githubusercontent.com/dmkoch/django-jsonfield/

## PreRequisites
To use oracle-json-field you will need Django 2.0+ and Python3+

## Installation
Install via pip

pip install oracle-json-field

Or install via source

python setup.py install

## Setup
Update Django settings as follows

INSTALLED_APPS += ('oracle_json_field',)


## Define your models

from oracle_json_field.fields import JSONField
from oracle_json_field.managers import JsonQueryManager

class JsonModel(models.Model):
json = JSONField()
default_json = JSONField(default={"key1": 50})
complex_default_json = JSONField(default=[{"key1": 50}])
empty_default = JSONField(default={})

objects = JsonQueryManager()



## Create and **Natively** query any field in your json
JsonModel.objects.create(json={
"person": {
"age": 25,
"first_name": "Joe",
"last_name": "Blogs",
"address": {
"number": "52",
"street": "Here Terrace",
"post_code": "ABC 123",
"city": "Anytown",

}
}
})

JsonModel.objects.filter_json(json__person__first_name='Joe')
JsonModel.objects.filter_json(json__person__first_name__startswith='J')
JsonModel.objects.filter_json(json__person__address__city__in=['Anytown', 'Sometown'])
JsonModel.objects.filter_json(json__person__age__gte=25)



## Running the test suite:
In order to run the test suite, you will need to create an oracle user
and export the following environment variables:

ORACLE_JSON_HOST
ORACLE_JSON_PORT
ORACLE_JSON_SID
ORACLE_JSON_USER
ORACLE_JSON_PASS


This link describes how to setup the testing user:
https://code.djangoproject.com/wiki/OracleTestSetup

Then run the following command

python setup.py test

You should then see:

running test
Creating test database for alias 'default'...
Creating test user...
System check identified no issues (0 silenced).
......................................
Preserving test database for alias 'default'...
----------------------------------------------------------------------
Ran 38 tests in 4.900s

OK

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oracle-json-field-0.0.7.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

oracle_json_field-0.0.7-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file oracle-json-field-0.0.7.tar.gz.

File metadata

  • Download URL: oracle-json-field-0.0.7.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for oracle-json-field-0.0.7.tar.gz
Algorithm Hash digest
SHA256 0fe06274723b4d74a827c461ee05bcc86945d82ab2d95c83e11639ca37830c50
MD5 45981f400ed38309fb8be14c5d3a0b78
BLAKE2b-256 f152dfa334278aacee42abdbc346b3697273ac78249350bc3dfeff2b1eccc2b6

See more details on using hashes here.

File details

Details for the file oracle_json_field-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: oracle_json_field-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for oracle_json_field-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ee9dcab2154d6432420f1aedfe5802710982ac3c90fae82324e086ffc6e002ef
MD5 56f22a73b482d5fb43094b50d93ad739
BLAKE2b-256 e6c72793ad305842083175f716e6e851e3955e42e5c26220783048c36d7fb48e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page