当前位置:   article > 正文

uniapp使用sqlite_uniapp 关闭sqlite

uniapp 关闭sqlite

1、判断数据库是否打开

  1. isOpen() {
  2. let open = plus.sqlite.isOpenDatabase({
  3. name: this.dbName,
  4. path: this.dbPath
  5. })
  6. return open;
  7. }

2、创建数据库(有就打开)

  1. openSqlite() {
  2. return new Promise((resolve, reject) => {
  3. plus.sqlite.openDatabase({
  4. name: this.dbName,
  5. path: this.dbPath,
  6. success(e) {
  7. resolve(e);
  8. },
  9. fail(e) {
  10. reject(e);
  11. }
  12. })
  13. })
  14. }

3、关闭数据库

  1. closeSqlite() {
  2. return new Promise((resolve, reject) => {
  3. plus.sqlite.closeDatabase({
  4. name: this.dbName,
  5. success(e) {
  6. resolve(e);
  7. },
  8. fail(e) {
  9. reject(e);
  10. }
  11. })
  12. })
  13. }

4、执行sql

  1. createTable(dbTable, data) {
  2. return new Promise((resolve, reject) => {
  3. plus.sqlite.executeSql({
  4. name: this.dbName,
  5. sql: `CREATE TABLE IF NOT EXISTS ${dbTable}(${data})`,
  6. success(e) {
  7. resolve(e);
  8. },
  9. fail(e) {
  10. reject(e);
  11. }
  12. })
  13. })
  14. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/426391
推荐阅读
相关标签
  

闽ICP备14008679号