tablespoon

2019-12-03

tablespoon是什么

什么是tablespoon,A NodeJS postgres wrapper to easily create tabls from json or csv data and run queries.

tablespoon使用教程帮助文档

Tablespoon

This repository is no longer being maintained. Please use https://github.com/mhkeller/tablespoon2.

Easily query spreadsheet-like or json data with SQLite or PostgreSQL. Built around node-postgres and 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 wiki for the latest documentation and the FAQ, which includes helpful tips on how to load in csv or tsv data 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 postgres role unless you change the connection string your own role. Create with createuser -s -r postgres from the command line.

Used in

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


上一篇:dsv
下一篇:tktk
相关文章
暂无相关文章

首次访问,人机识别验证

扫描下方二维码回复 1024 获取验证码,验证完毕后 永久 无须验证

操作步骤:[打开微信]->[扫描上侧二维码]->[关注 FedJavaScript 的微信] 输入 1024 获取验证码

验证码有误,请重新输入