okfn/jts-sql-js

Name: jts-sql-js

Owner: Open Knowledge International

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

Created: 2015-09-28 06:57:06.0

Updated: 2018-02-09 06:20:47.0

Pushed: 2015-10-17 21:13:15.0

Homepage: https://www.npmjs.com/package/jts-sql-js

Size: 156

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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:

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

our rows of data - maybe you loaded these from a CSV :-)
data = [
foo': 3, 'bar': 'hello'},
foo': 5, 'bar': 'bye'}


his is your JSON Table Schema - http://dataprotocols.org/json-table-schema/
schema = {
ields': [
{
  'name': 'foo',
  'type': 'integer'
},
{
  'name': 'bar',
  'type': 'string'
}



engine = new Sequelize('datastore', 'datastore', '', {
alect: 'sqlite',
orage: './example.db'


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

Tests

npm test


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.