tablespoon

A NodeJS postgres wrapper to easily create tabls from json or csv data and run queries.

Tablespoon

Easily query spreadsheet-like or json data with SQLite or PostgreSQL. Built aroundnode-postgresand node-sqlite3.

Installation

To install as a Node.js module

npm install tablespoon

To use Tablespoon's command line interface, install with the global flag

npm install tablespoon -g

If you want to use Tablespoon in both circumstances, run both commands.

Documentation

Check out the wikifor the latest documentation and the FAQ, which includes helpful tipson how to load in csvor tsvdata into Node.js.

Example usage

See more examples.

var ts = require('tablespoon.js').pgsql();

var data = [
    {
        city: "New York",
        temp: [0,35],
        country: 'USA'
    },
    {
        city: 'Los Angeles',
        temp: [15,35],
        country: 'USA'
    },
    {
        city: 'Paris',
        temp: [2,33],
        country: 'France'
    },
    {
        city: 'Marseille',
        temp: [5,27],
        country: 'France'
    },
    {
        city: 'London',
        temp: [2,25],
        country: 'UK'
    }
]

ts.createTable(data, 'cities')

// Get the rows that don't have 15
ts.query('SELECT * FROM cities WHERE 15 != ALL (temp)', function(rows){
    console.log(rows)
    /*{ 
    query: 'SELECT * FROM cities WHERE 15 != ALL (temp)',
  rows:
   [ { uid: '1', city: 'New York', temp: [0,35], country: 'USA' },
     { uid: '3', city: 'Paris', temp: [2,33], country: 'France' },
     { uid: '4', city: 'Marseille', temp: [5,27], country: 'France' },
     { uid: '5', city: 'London', temp: [2,25], country: 'UK' } ] }*/
})

Testing

Examples and testing require a postgresrole unless you change the connection string your own role. Create with createuser -s -r postgresfrom the command line.

Used in

Analysis for Nominated for the Oscars but failing the Bechdel sexism test- Al Jazeera America

HomePage

https://github.com/ajam/tablespoon

Repository

https://github.com/ajam/tablespoon.git


上一篇:dsv
下一篇:tktk

相关推荐

暂无相关文章

官方社区

扫码加入 JavaScript 社区