Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Library for converting JSON Table Schema to an SQL table, for Node and the browser.

License

Notifications You must be signed in to change notification settings

frictionlessdata/tableschema-sql-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jts-sql-js

Library for converting JSON Table Schema to an SQL table, for Node and the browser.

Usage

Here's an example of using jts-sql-js:

var Sequelize = require('sequelize');
var SchemaTable = require('jts-sql-js').SchemaTable;
var streamify = require('stream-array'); // only needed to turn array -> stream

// your rows of data - maybe you loaded these from a CSV :-)
var data = [
  {'foo': 3, 'bar': 'YES'},
  {'foo': 5, 'bar': 'NO'}
];

// this is your JSON Table Schema - http://dataprotocols.org/json-table-schema/
var schema = {
  'fields': [
    {
      'name': 'foo',
      'type': 'integer'
    },
    {
      'name': 'bar',
      'type': 'string',
      'constraints': {
          'required': true,
          'enum': ['YES', 'NO']
      }
    }
  ]
};

var engine = new Sequelize('datastore', 'datastore', '', {
  dialect: 'sqlite',
  storage: './example.db'
});

var table = SchemaTable(engine, 'foo_table', schema);
table.create().then(function () {
  table.load_iter(streamify(data));
});

Tests

npm test

About

Library for converting JSON Table Schema to an SQL table, for Node and the browser.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •