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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-adodb

v5.0.3

Published

A Node.js JavaScript Client implementing the ADODB protocol.

Downloads

7,965

Readme

node-adodb

一个用 Node.js 实现的 windows 上的 ADODB 协议。

NPM Version Download Status Windows Status Test Coverage Node Version Dependencies

安装

NPM

使用示例:

ES6
'use strict';

const ADODB = require('node-adodb');
const connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

// 不带返回的执行
connection
  .execute('INSERT INTO Users(UserName, UserSex, UserAge) VALUES ("Newton", "Male", 25)')
  .then(data => {
    console.log(JSON.stringify(data, null, 2));
  })
  .catch(error => {
    console.error(error);
  });

// 带返回标识的执行
connection
  .execute('INSERT INTO Users(UserName, UserSex, UserAge) VALUES ("Newton", "Male", 25)', 'SELECT @@Identity AS id')
  .then(data => {
    console.log(JSON.stringify(data, null, 2));
  })
  .catch(error => {
    console.error(error);
  });

// 带返回的查询
connection
  .query('SELECT * FROM Users')
  .then(data => {
    console.log(JSON.stringify(data, null, 2));
  })
  .catch(error => {
    console.error(error);
  });

// 带字段描述的查询
connection
  .schema(20)
  .then(schema => {
    console.log(JSON.stringify(schema, null, 2));
  })
  .catch(error => {
    console.error(error);
  });
ES7 async/await
'use strict';

const ADODB = require('node-adodb');
const connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

async function query() {
  try {
    const users = await connection.query('SELECT * FROM Users');

    console.log(JSON.stringify(users, null, 2));
  } catch (error) {
    console.error(error);
  }
}

query();

接口文档:

ADODB.open(connection[, x64]): ADODB

初始化数据库链接参数。

ADODB.query(sql): Promise

执行有返回值的 SQL 语句。

ADODB.execute(sql[, scalar]): Promise

执行无返回值或者带更新统计的的 SQL 语句。

ADODB.schema(type[, criteria][, id]): Promise

查询数据库架构信息。参考: OpenSchema

调试:

设置环境变量 DEBUG=ADODB。参考: debug

扩展:

该类库理论支持 Windows 平台下所有支持 ADODB 连接的数据库,只需要更改数据库连接字符串即可实现操作!

数据库连接字符串:

  • Access 2000-2003 (*.mdb): Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;
  • Access > 2007 (*.accdb): Provider=Microsoft.ACE.OLEDB.12.0;Data Source=adodb.accdb;Persist Security Info=False; 或者   Provider=Microsoft.ACE.OLEDB.15.0;Data Source=adodb.accdb;Persist Security Info=False;

注意:

该类库需要系统支持 Microsoft.Jet.OLEDB.4.0 或者 Microsoft.ACE.OLEDB.12.0,对于 Windows XP SP2 以上系统默认支持 Microsoft.Jet.OLEDB.4.0,其它需要自己安装支持!

推荐使用 Microsoft.ACE.OLEDB.12.0,获取地址: Microsoft.ACE.OLEDB.12.0

Electron

如果你想在 ASAR 包中运行这个模块,你需要做一些修改。

  1. asar 包中排除 adodb.js(使用 electron-builder, 可以配置 extraResources 将制定文件排除在外)
"extraResources": [
  {
    "from": "./node_modules/node-adodb/lib/adodb.js",
    "to": "adodb.js"
  }
]
  1. 告诉 asar 从哪里运行 adodb.js (可以将配置写在 Electronmain.js 文件中)
// Are we running from inside an asar package ?
if (process.mainModule.filename.indexOf('app.asar') !== -1) {
  // In that case we need to set the correct path to adodb.js
  ADODB.PATH = './resources/adodb.js';
}