data2model

Saves XML and CSV data to a database - based on models

This packages aims on providing a high performance, fast and convenient way to save data obtained via XML or CSV files. It uses LOAD DATA LOCAL INFILE for CSV files and parses XML (using sax-js)data according to your models. Everything is created for you.

You can create models with the model creator. The model creator requires redis for convenience, but currently only saves your databases. Redis uses database 10 by default and for now only creates an entry called modelCreator_database in redis.

Installation

npm i data2model --save

What it does

For the sake of this example, it creates this INSERT ... ON DUPLICATE KEY UPDATE query:

and executes the query, given the exampleModel found in the models directory.

Important

Very new package, so there might be some bugs and issues.

Feel free to contribute or to post any issues. Needs node.js version >= 4.0.0.

Usage

For now, run node with the --harmony_destructuring flag as it isn't finally implemented.

Copy (or create a new one) the .env.example file to .env in your apps root dir and fill in your credentials. You don't need to specify a database here. 1.1. Get the dot notation for your xml file. See dotNotation for how to.

Start redis, create a file with this contents:

var data2model = require('data2model'); new data2model.creator();

run it and follow the instructions. This will launch the model creator and will ask you for some details. 3. Have a look at the generated file inside the /models directory, you can add valueOptions, defaultValues and whatsoever 4. Once done, saving XML data is as simple as: