sqlite
提供 sqlite_open、one、all、exec、transaction 和 query().bind() 等 SQLite 能力。

sqlite

提供 sqlite_open、one、all、exec、transaction 和 query().bind() 等 SQLite 能力。

官方
安装命令
bt install sqlite bt install sqlite 1.0.0

公开 API

  • sqlite_open()返回 Sqlite
  • Sqliteone、all、exec、transaction、query、close
  • SqliteQuerybind、one、all、exec、close

sqlite

BT 官方 SQLite shared WASM 扩展,用于在 BT 项目中直接访问本地 SQLite 数据库文件。

安装

指定版本:

安装后扩展包会进入当前项目:

能力

  • sqlite_open(path, options) 打开 SQLite 数据库并返回 Sqlite 对象。
  • one(sql, params) 查询单行;无结果返回 empty,SQLite NULL 返回 null
  • all(sql, params) 查询多行,并受 max_rowsmax_result_bytes 限制。
  • exec(sql, params) 执行写入语句并返回影响行数。
  • transaction(statements) 串行执行同一事务中的多条语句。
  • query(sql).bind(value) 提供链式参数绑定。

权限

该扩展需要读写项目目录内的数据库文件:

示例