1,安裝 sqlite3:npm install sqlite3
2,設定 node_modules 資料夾的路徑:(在我的電腦上是:C:\Documents and Settings\Administrator\node_modules)
My Computer > Properties > Advanced system settings > Environment Variables
這樣就大功告成了。
以下是我測試的程式碼?
var sqlite3 = require("sqlite3").verbose();
var db = new sqlite3.Database(":memory:");
db.serialize(function() {
db.run("CREATE TABLE person (name TEXT)");
var stmt = db.prepare("INSERT INTO person VALUES (?)");
for (var i = 0; i < 10; i++) {
stmt.run("玉兔 " + i);
}
stmt.finalize();
db.each("SELECT rowid AS id, name FROM person", function(err, row) {
console.log(row.id + ": " + row.name);
});
db.close()
1,安裝 sqlite3:npm install sqlite3
2,設定 node_modules 資料夾的路徑:(在我的電腦上是:C:\Documents and Settings\Administrator\node_modules)
My Computer > Properties > Advanced system settings > Environment Variables
這樣就大功告成了。
以下是我測試的程式碼?
var sqlite3 = require("sqlite3").verbose();
var db = new sqlite3.Database(":memory:");
db.serialize(function() {
db.run("CREATE TABLE person (name TEXT)");
var stmt = db.prepare("INSERT INTO person VALUES (?)");
for (var i = 0; i < 10; i++) {
stmt.run("玉兔 " + i);
}
stmt.finalize();
db.each("SELECT rowid AS id, name FROM person", function(err, row) {
console.log(row.id + ": " + row.name);
});
});
db.close()