本文整理汇总了TypeScript中sqlite3.Database.close方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Database.close方法的具体用法?TypeScript Database.close怎么用?TypeScript Database.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlite3.Database
的用法示例。
在下文中一共展示了Database.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: users
.then(data => {
db.run(
"insert into users (username, salt, hashedpwd) values (?, ?, ?)",
[data.username, data.salt, data.hash], cb // Null on success, single error parameter on success
);
db.close();
});
示例2: reject
(err) => {
db.close();
if (err) {
reject(err);
} else {
resolve();
}
});
示例3: setupDatabase
/**
* Caution: resets database.
*/
static setupDatabase() {
try {
fs.unlinkSync(DB_PATH);
} catch (err) { }
let db = new Database(DB_PATH);
try {
db.serialize(() => {
db.run(`
CREATE TABLE users (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
username TEXT NOT NULL UNIQUE,
salt TEXT NOT NULL,
hashedpwd TEXT NOT NULL,
admin INTEGER NOT NULL DEFAULT 0
);
`);
db.run(`
CREATE TABLE entries (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
date TEXT NOT NULL,
hungerscore INTEGER NOT NULL,
hungertext TEXT,
cravingscore INTEGER NOT NULL,
cravingtext TEXT,
satietyscore INTEGER NOT NULL,
satietytext TEXT,
energyscore INTEGER NOT NULL,
energytext TEXT,
wellbeingscore INTEGER NOT NULL,
wellbeingtext TEXT,
carbsscore INTEGER NOT NULL,
carbstext TEXT,
stressambool INTEGER NOT NULL,
stresspmbool INTEGER NOT NULL,
walksbool INTEGER NOT NULL,
movementbool INTEGER NOT NULL,
movementtext TEXT,
bedtimebool INTEGER NOT NULL,
bedtimetext TEXT,
userid INTEGER NOT NULL,
FOREIGN KEY(userid) REFERENCES user(id)
);
`);
});
}
catch (err) { console.error(err); }
finally {
db.close();
}
}
示例4: resolve
return new Promise<any>((resolve, reject) => {
if (!this._db) {
resolve();
} else {
this._db.close(err => {
if (err) {
reject(err);
} else {
this._db = undefined;
resolve();
}
});
}
});
示例5: cities
for (var key in dict_aa)
{
var sql_str:string = "insert into cities (id,name,population,date_mod) values (";
var str_data: string = "'" + key + "','" + dict_aa[key].name + "',"
+ dict_aa[key].population + ",'" + dict_aa[key].date_mod + "')";
sql_str += str_data;
db.run (sql_str);
}
});
}
// ------------------------------------------------------------
console.log ("*** 開始 ***");
var file_sqlite3: string = process.argv[2];
console.log (file_sqlite3);
var dict_aa = data_prepare_proc ();
var db = new sqlite3.Database (file_sqlite3);
table_create_insert_proc (db,dict_aa);
db.close ();
console.log ("*** 終了 ***");
// ------------------------------------------------------------
示例6:
.then(() => {
console.log('close db..')
db.close();
});