Skip to content

Commit

Permalink
working CLI
Browse files Browse the repository at this point in the history
node index.js "SELECT * FROM content WHERE field_id='19'"

or, for write mode:

node index.js "SELECT * FROM content WHERE field_id='19'" true
  • Loading branch information
ryandellolio committed Mar 16, 2019
1 parent 6577bea commit 7885c2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
25 changes: 20 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@
//TODO - have dnsdb provide output to re-save to DB

var dnsDB = require('./dnsDB.js');
var query = process.argv[2];

var save = dnsDB('dns#v1-1.dellol.io', "key", true, function ( db, close ){ //creates a sqlite3 db from a DNS call. true denotes write mode
if(process.argv[3] == "true")
var writeMode = true;
else
var writeMode = false;


var save = dnsDB('dns#v1-1.dellol.io', "key", writeMode, function ( db, close ){ //creates a sqlite3 db from a DNS call. true denotes write mode

db.serialize(function() { //use as you normally would per https://www.npmjs.com/package/sqlite3

db.each("SELECT * FROM content", function(err, row) {
db.each(query, function(err, row) {
if(err)
console.log('\x1b[31m%s\x1b[0m', err);
if(row)
console.log('\x1b[32m%s\x1b[0m', row.field_id + " | " + row.name + " | " + row.value);
});

});

db.exec("INSERT INTO content VALUES(29,'descriptidescriptiondescriptiondescriptiondescriptionon','<p>Stella</p>')");
/*
//programatic example
db.each("SELECT * FROM CONTENT", function(err, row) {
if(err)
console.log('\x1b[31m%s\x1b[0m', err);
if(row)
console.log('\x1b[32m%s\x1b[0m', row.field_id + " | " + row.name + " | " + row.value);
});
*/

});

Expand Down
1 change: 0 additions & 1 deletion lastPlainText.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ INSERT INTO content VALUES(9,'description','<p>Stella</p>');
INSERT INTO content VALUES(15,'description','<p>Stella</p>');
INSERT INTO content VALUES(18,'description','<p>Stella</p>');
INSERT INTO content VALUES(19,'description','<p>Stella</p>');
INSERT INTO content VALUES(29,'descriptidescriptiondescriptiondescriptiondescriptionon','<p>Stella</p>');
INSERT INTO content VALUES(44,'description','<p>Stella</p>');
DELETE FROM sqlite_sequence;
INSERT INTO sqlite_sequence VALUES('content',44);
Expand Down

0 comments on commit 7885c2a

Please sign in to comment.