sqlite-json-export
Convert Sqlite3 tables to JSON
Install
npm install --save sqlite-json-export
Todo:
- Migrate to a Promise based API
- Extract all tables
API
constructor(database)
Create an instance of sqlite-json.
Example:
const SqliteJsonExport = ;let exporter = 'example.db';
database
The path to an SQLite database or a sqlite3 client instance.
Type: sqlite3.Database
or string
Example:
const SqliteJsonExport = ;const sqlite3 = ;const db = './mydb.sqlite3';const exporter = 'example.db';
json(sql, options, callback)
Export JSON from a specified table, and use it in the given callback.
Example:
exporter;
options.columns
An optional list of columns to output.
Type: Array
Example:
exporter;
options.key
An optional column name.
By default, the result is an JSON array of objects. If key
is given, a JSON object is returned, each row keyed to the given column value.
Type: string
Example:
exporter;
options.table
A table to address with the columns
, and where
options.
Type: string
options.where
A where clause to add to the query.
Type: string
Example:
exporter;
tables(cb)
List all tables in the current database.
Example:
exporter;
save(table, filename, cb)
Save the contents of a table to the specified output file.
Example:
exporter;