SQLite3 в NodeJS

Материал из support.qbpro.ru

Пример кода

var sqlite3 = require('sqlite3').verbose();
/*var db = new sqlite3.Database(':memory:');*/
var db = new sqlite3.Database('/home/klimov/Desktop/nixtech/server/nodejs/test.db');

db.run('PRAGMA foreign_keys = ON');
db.run('PRAGMA synchronous = OFF');
db.run('PRAGMA journal_mode = MEMORY');
db.run('PRAGMA page_size = 8192');
db.serialize(function () {
	db.run("CREATE TABLE lorem (info TEXT)");

	var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
	for (var i = 0; i < 100000; i++) {
		stmt.run("IpsumМаша " + i);
	}
	stmt.finalize();

	db.each("SELECT rowid AS id, info FROM lorem", function (err, row) {
		console.log(row.id + ": " + row.info);
	});
});

db.close();

Установка

npm install sqlite3