i Have problem with SQlite3 and Vue2
I'm using Electron-Vue, and I have installed SQLite3 and Require it Successfully (database.db)
using this:
var sqlite3 = require('sqlite3').verbose();
var path = require('path')
var db = new sqlite3.Database(path.join(__dirname, '..', '/../','db', 'database.db'));
So next Step its difficult to me (Basic Crud System)?
How to Add Like this Code to A Vue Component
db.serialize(function() {
db.run("CREATE TABLE lorem (info TEXT)");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();
var rows = document.getElementById("database");
db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
var item = document.createElement("li");
item.textContent = "" + row.id + ": " + row.info;
rows.appendChild(item);
});
});
db.close();
Just a simple demo code to get started with VueJS2 Component and SQlite3!!