3

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!!

nbdized
  • 105
  • 2
  • 12
  • Are you using single file components or do you just want that script in your Electron render window? – Bert Apr 17 '17 at 16:23
  • I'm just trying to get DATA from DB and load it to a VUE Component, also push data to DB from Vue Components, using electron-vue ?? – nbdized Apr 19 '17 at 13:40

0 Answers0