1、判断数据库是否打开
isOpen() {
let open = plus.sqlite.isOpenDatabase({
name: this.dbName,
path: this.dbPath
})
return open;
}
2、创建数据库(有就打开)
openSqlite() {
return new Promise((resolve, reject) => {
plus.sqlite.openDatabase({
name: this.dbName,
path: this.dbPath,
success(e) {
resolve(e);
},
fail(e) {
reject(e);
}
})
})
}
3、关闭数据库文章来源:https://www.toymoban.com/news/detail-834007.html
closeSqlite() {
return new Promise((resolve, reject) => {
plus.sqlite.closeDatabase({
name: this.dbName,
success(e) {
resolve(e);
},
fail(e) {
reject(e);
}
})
})
}
4、执行sql文章来源地址https://www.toymoban.com/news/detail-834007.html
createTable(dbTable, data) {
return new Promise((resolve, reject) => {
plus.sqlite.executeSql({
name: this.dbName,
sql: `CREATE TABLE IF NOT EXISTS ${dbTable}(${data})`,
success(e) {
resolve(e);
},
fail(e) {
reject(e);
}
})
})
}
到了这里,关于uniapp使用sqlite的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!