0.4.0 • Published 9 years ago
tablespoon v0.4.0
Tablespoon
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