Skip to content

Instantly share code, notes, and snippets.

@diestrin
Created September 11, 2013 19:52
Show Gist options
  • Save diestrin/6528883 to your computer and use it in GitHub Desktop.
Save diestrin/6528883 to your computer and use it in GitHub Desktop.
{
"name": "SQLiteToJSON",
"version": "0.0.0",
"description": "Convert a SQLite db to json objects",
"main": "app.js",
"dependencies": {},
"devDependencies": {
"sqlite3": "~2.1.16"
},
"author": "Diego Barahona <diestrin@gmail.com>"
}
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('./DB.db');
db.serialize(function() {
db.each("SELECT * FROM sqlite_master WHERE type='table'", function(err, table) {
db.each("SELECT * FROM " + table.tbl_name, function(err, row) {
console.log("Table: " + table.tbl_name);
console.log(row);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment