sequel-csv

1.6.1 • Public • Published

Sequel-CSV

Package for executing simple sql queries against a csv file.

Buy Me a Coffee at ko-fi.com

Installation

NPM

npm i sequel-csv

Yarn

yarn add sequel-csv

Documentation on GitHub

Usage

./table.csv
userId,level
1,5
2,10
3,40
main.js
const { Database } = require('./package/index.js');
const database = new Database();

/*
By default when registering a new table the table name is taken from the file name, excluding path and
extension.
To set a custom schema name provide the name as a string in the second parameter.
 */
database.registerSchema('./table.csv')

//Get all rows
const results = await table.query('SELECT * FROM test');
console.log(results) // [{ userId: 1, level: 5 }, { userId: 2, level: 10 }, { userId: 3, level: 40 }]

//Examples of filtering results
const results = await table.query('SELECT * FROM test WHERE level > 10');
console.log(results); // [{ userId: 3, level: 40 }]

const results = await table.query('SELECT * FROM test WHERE userId = 1');
console.log(results); // [{ userId: 1, level: 5 }]

Package Sidebar

Install

npm i sequel-csv

Weekly Downloads

0

Version

1.6.1

License

ISC

Unpacked Size

26.5 kB

Total Files

7

Last publish

Collaborators

  • finbar