node_sqlite_usage/index.js

16 lines
414 B
JavaScript
Raw Normal View History

2020-01-31 00:16:29 -05:00
var s = require('sqlite3');
var db = new s.Database('osm.db3');
db.serialize(function() {
db.run("CREATE TABLE IF NOT EXISTS sales(cust text, part text, value numeric)");
});
db.serialize(function() {
db.run("INSERT INTO sales VALUES ('Agri AFC','nsr001g',.50)");
});
db.each("SELECT cust, part FROM sales", function(err, row) {
console.log(row.cust + ": " + row.part);
});
db.close;