json2oraparser
The 'json2oraparser' library parses a JSON file (nested upto n-th level) according to the metadata file provided by user and stores the Json data into Oracle database.
Program reads the user given metadata for one time and looks it up while traversing through the Json file level wise (it can well parse a complex Json nested upto n-th level) to build normalized path of each Json key at runtime and extracts all the required database related information like exact table name, column name, datatype by referencing the metadata to generate all insert sql statements which subsequently gets executed in database to finally load Json data into Oracle database.
Pre-Requisite and Assumption :
- Python should be installed in system. The recommended Python version for this library is v2.7. For higher version of Python, updated library version will be released later.
- Oracle client should be available in the system.
- Oracle database, tables, columns related to json data need to be available
- Library supports only the following date/timestamp format from Json file –
Y-m-dTH:M:S.fZ (e.g. 2018-07-29T17:44:27.633Z), Y-m-dTH:M:S.f,
Y-m-d H:M:S.f, Y-m-d H.M.S.f, Y-m-d H:M:S, Y-m-d H.M.S, Y-m-d
Installation :
pip install json2oraparser
Usage :
import json2oraparser
metadata = json2oraparser.createMetadata (C:/Event_Metadata.csv)
json2oraparser.loadJson (C:/Event2019.json, metadata, 111.11.11.11, 1111, EVNT, EVNT_USR, EvntPassword@1)
Overview :
The entire project operation is a 2 step process –
-
STEP 1: METADATA CREATION :
The sample code piece related to this step is - metadata = json2oraparser.createMetadata (C:/Event_Metadata.csv)
json2oraparser.createMetadata() :
This function will take a csv file (with absolute file path) as input and produces a list of metadata built according to the CSV. This CSV file template ( 'Metadata_Blank_Template.csv' ) is provided in the 'METADATA' folder which will be available after library installation. Please note, all the column names in the CSV should match with template file.
According to the Json file, user needs to create the CSV file which will contain information about different Json entity and attribute names and their corresponding database table and column details where the Json fields will be stored.
A sample Json data file - Sample_Json_File.json - is given for your reference in 'METADATA' folder.
A sample metadata file - Sample_Metadata_with remarks.csv - has been built (available in 'METADATA' folder) as per the Sample Json (with relevant explanation/remarks in '_Remarks_' column). Please note, '_Remarks_' column is added for your reference only, it should NOT be part of the metadata CSV file.
Metadata CSV File Description :
Metadata CSV file preparation with proper information and correct format is the backbone of this library's successful execution. The detailed description of different columns in the metadata CSV file as well as the instruction for filling up each of those columns have been given in the file ' Metadata_CSV_Preparation_Guide.txt' within 'METADATA' folder. The same description is also given below -
FIELD_ID : Unique identifier and serial number for each row in the csv.
ENTITY_NAME : Node names (e.g. object/list) from Json file.
ATTRIBUTE_NAME : Key names from Json file.
NODE_LEVEL : Level of any node in json file. Starting node level is denoted as '1', subsequent child level will be continued as 2, 3, 4... In the sample Json, the starting node name is 'event'.
TABLE_NAME : Database table name where the entity will be stored. This can be filled up either by table synonyms (e.g. T_RL_RE) or by prefixing schema name [SchemaName].[TableName] (e.g. MARKET.OVR). Typically one json ENTITY_NAME corresponds to one database TABLE_NAME. If you don't want to load an entire node's data into its corresponding database table, mark the TABLE_NAME as 'DUMMY' in CSV instead of leaving the field as blank.
COLUMN_NAME : Database table name where the attribute value will be stored. This basically represents the granularity of the entire metadata.
PARENT_NODE : Immediate parent node of any node in Json file. It is filled up as [parent ENTITY_NAME] | [starting FIELD_ID of that parent node] (e.g. Abs|7).
NODE_PATH : This field needs to be used for all node level of the json. For Level 1, starting node name from the json of this level should be given as NODE_PATH. For remaining levels, there is no need to fill up this column.
ROOT_FLAG : Starting ROOT_FLAG of each node will be 1, for other attributes of that node ROOT_FLAG = 0.
CURRENT_IND : This field must be filled up as 'Y' for loading any column in database. In case, you don't want to load any particular column of a table (even though it's corresponding attribute is present in Json), fill it up as 'N'.
LOGICAL_DATATYPE : Datatype of the database column where you want to store json attribute value.
PARENT_COLUMN : If you want to load a particular column of a node with the value of any attribute of immediate parent node then PARENT_COLUMN field needs to be used. Please note, the entry in PARENT_COLUMN field in CSV must exist in Json and should belong to immediate parent node of the current entity.
-
STEP 2: LOAD JSON TO ORACLE DATABASE :
The sample code piece related to this step is - json2oraparser.loadJson (C:/Event2019.json, metadata, 111.11.11.11, 1111, EVNT, EVNT_USR, EvntPassword@1)
json2oraparser.loadJson() :
User needs to provide the following parameters to this function as per the below sequence to load a Json file's data into Oracle database -
- A valid Json file (with absolute file path)
- Metadata variable created in STEP 1
- Oracle database 'Hostname'
- Oracle database 'Port'
- Oracle database 'SID' or 'Service name'
- Oracle database 'Username'
- Oracle database 'Password'
Contact Info :
For any query/clarification/issue regarding the 'json2oraparser' library, please mail to ntpythondev@gmail.com .
Metadata
Release files for json2oraparser 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json2oraparser-1.0.2.tar.gz | 14.1 kB | Without provenance | Details for json2oraparser-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json2oraparser-1.0.2-py2-none-any.whl | Python 2 | none | any | Details for json2oraparser-1.0.2-py2-none-any.whl |
Total release size: 33.5 kB
Release files / json2oraparser-1.0.2.tar.gz
| Download URL | json2oraparser-1.0.2.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe6ac502f94f24873ac4a7650299b0b196e4484246131263b4deaf8d13aa6409
|
|
BLAKE2b-256 checksum How to use checksums |
714ce6b46875e31bd9b00bfd7704d0166577f8d6529663de82f650f03536fc42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16
|
Release files / json2oraparser-1.0.2-py2-none-any.whl
| Download URL | json2oraparser-1.0.2-py2-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
a27fa0495e252c910b8c4c2dc7501b187289b105bcbe1a66e53f476765a62c64
|
|
BLAKE2b-256 checksum How to use checksums |
a959eef7812bfc4064c99ff5839df2ac099405781e0ab4bd081744accc5595ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16
|
Security for json2oraparser 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.