npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mini-sqlite3

v0.1.1

Published

SQLITE3 扩展

Readme

min-sqlite3

说明

slqite3 扩展库

下载实际的addon

http://linuxmail.cn/go#node-mini-sqlite3

下载合适的版本,改名为 mini_sqlite3_addon.node, 放置到项目目录, 或者 项目目录的lib目录下.

程序打包的时候,记得打包这个文件

用法及例子

import { sqlite3Client } from "mini-sqlite3"

let sql = `
CREATE TABLE IF NOT EXISTS base_config (
  key STRING NOT NULL DEFAULT '', 
  val TEXT NOT NULL DEFAULT '', 
  PRIMARY KEY (key)
);
`
// new 一个对象
let db = new sqlite3Client()

const test = async () => {

	// 打开一个数据库, 返回 boolean
	db.open({ "dbName": "./a.db" })
	// 申请一个worker 
	await db.worker(async (w) => {
		// 事务模式执行一条语句或多条, 同步
		// sql: string|string[],返回 boolean
		w.transactionExec(sql)
		// 事务内执行, 同步
		w.transaction(() => {
			// 申请一个"预处理"
			let stmt = w.stmt()
			// 编译预处理, 返回 boolean
			stmt.prepare("INSERT OR IGNORE INTO base_config(key, val)values(:key, :val);")
			for (let i = 100; i < 1000; i++) {
				// 绑定, 返回 boolean
				stmt.bind({ key: "key_" + i, val: "val_" + i })
				// 执行, 返回 boolean
				stmt.run()
			}
		})
		w.transaction(() => {
			let stmt = w.stmt()
			stmt.prepare("UPDATE base_config SET val=:val WHERE key LIKE '%'||:valAAA||'%'")
			stmt.bind({ valAAA: 555 })
			stmt.run()
		})

		//
		let stmt = w.stmt()
		stmt.prepare("SELECT * FROM base_config LIMIT 1,2")
		stmt.stepByStep((row) => {
			console.log("AAA", row)
		})

		//
		stmt.prepare("SELECT * FROM base_config WHERE key LIKE '%'||:keyPPP||'%' LIMIT 3")
		stmt.bind({ keyPPP: "key_99" })
		stmt.stepByStep((row) => {
			console.log("BBB", row)
		})

		//
		stmt.prepare("SELECT * FROM base_config WHERE key LIKE '%'||?||'%' LIMIT 3")
		stmt.bind(["key_99"])
		stmt.stepByStep((row) => {
			console.log("CCC", row)
		})

		//
		stmt.prepare("SELECT * FROM base_config WHERE key LIKE '%'||?||'%' LIMIT 3")
		stmt.bind(["key_99"])
		// 单步执行
		while (1) {
			let r = stmt.step()
			if (!r.status) {
				console.error("db error")
				break;
			}
			let row = r.row
			if (!row) {
				break
			}
			console.log("DDD", row)
		}

		//
		stmt.prepare("SELECT * FROM base_config WHERE key LIKE '%'||?||'%' LIMIT 3")
		stmt.bind(["key_99"])
		let rows = stmt.runAndGetAllRows();
		if (!rows.status) {
			console.error("db error")
		} else {
			console.log("EEE", rows.rows)
		}
	})
}

test()