如何在 windowsXP 和 node.js 环境下,安装 sqlite3
1个回答
展开全部
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()
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()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询