How to Basic CRUD SQLite 3 with VueJs 2

I have a problem with SQlite3 and Vue2

I am 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 the next step is difficult for me (Basic Crud System)?

How to add this code to 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 !!

+3
sqlite3 electron vuejs2 node-sqlite3


source to share


No one has answered this question yet

Check out similar questions:

1031
How can I list tables in a SQLite database file that was opened with ATTACH?
652
What are the best practices for SQLite on Android?
407
Is there a SQLite equivalent for MySQL DESCRIBE [table]?
289
Core Data vs SQLite 3
212
How can I see the structure of a table in SQLite?
210
How do I remove or add a column in SQLITE?
158
SQLite parallel access
1
Unable to use sqlite in electronic rendering process: "Unable to read property" _handle "undefined"
0
Node.js Query sqlite with 'sqlite'
-1
how to load .vue files of vue project using node.js



All Articles
Loading...
X
Show
Funny
Dev
Pics