npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

json-to-rel

v1.0.2

Published

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1982b37edf4d44a0be92a2ffd304115b)](https://www.codacy.com/app/tomaszgil_2/json-to-rel?utm_source=github.com&utm_medium=referral&utm_content=tomaszgil/json-to-rel&utm_campaign=Badge_Gr

Downloads

7

Readme

json-to-rel

Codacy Badge

Transform JSON data object to relational form (sql or csv)

This package allows you to transform valid json object to relational form. The output of the application can be in a form of one .sql file with create table statements or a set of .csv files, with file names corresponding to table names.

Install

Using npm:

npm install --global json-to-rel

or using yarn:

yarn global add json-to-rel

Usage

Run the scipt using the command line

json-to-rel -i input-file.json -m sql -o output-dir/

Flags

| Setting | Description | Short flag | Full flag | Values | |---|---|---|---|---| | Input file | Path to a file with input JSON object | -i | --input | path/to/file.json | | Output directory | Path to a directory in which the application will store files with the results of the processing | -o | --output | path/to/direcory/ | | Mode | Type of data and files that will be generated | -m | --mode | sql | csv | | Logging | Activating optional logging to a file with log’s level of detail (the higher the value, the more detailed the log messages) | -l | --logging | 0 | 1 | 2 | | Configuration file | Path to file with additional configuration JSON object | -c | --config | path/to/file.json |

Ouput

  1. SQL

    A .sql file with a set of create table statements representing relational tables mapped from json object. Each table featutes a surrogate primary key. Tables are connected with foreign key constraints. Syntax is compliant with Sqlite 3.

  2. CSV

    A set of .csv files with file names corresponding to table names. Each file contains a header with table column names and rows which correspond to table records with values from input json object.

Configuration file

You can pass your own configuration file, which will override default configuration. Your configuration file can look like this.

{
  "inputFileEncoding": "utf8",
  "outputFileName": "tables.sql",
  "rootTableName": "GENERATED",
  "surrogatePrimaryKeyName": "__ID",
  "logFile": "json2rel.log",
  "csvDelimiters": {
    "col": ";",
    "row": "\n"
  },
  "generatedAttributeName": "value",
  "truncateTableName": false
}

More information

You can find detailed information using help.

json-to-rel --help

Contributions

Feel free to fork this github repository to find ways to improve this package.

Development

  1. Install dependencies

    npm install
  2. Run script

    npm start

    If you want to pass arguments to the script please use the following command with full parameter flags like so:

    npm start -- --input /path/to/input --mode sql --output /path/to/output

Building and testing

  1. Simulate package installation with npm link.
  2. Run the program with json-to-rel command followed by arguments.
  3. Remove package with npm unlink.