Non-blocking GaussDB client for Node.js.
This repo is a monorepo which contains the core gaussdb-node module as well as a handful of related modules.
- gaussdb-node
- gaussdb-pool
- gaussdb-cursor
- gaussdb-query-stream
- gaussdb-connection-string
- gaussdb-protocol
The maintained npm package is gaussdb-nodejs.
Install it directly and import from gaussdb-nodejs:
npm install gaussdb-nodejs@0.2.3 --registry=https://registry.npmjs.org/To keep existing require('gaussdb-node') or import ... from 'gaussdb-node'
code, install the same package using an npm alias:
npm install gaussdb-node@npm:gaussdb-nodejs@0.2.3 --registry=https://registry.npmjs.org/The old unscoped gaussdb-node package has not received this release.
Do not use npm install gaussdb-node@0.2.3 for this version.
The companion packages are gaussdb-nodejs-connection-string,
gaussdb-nodejs-pool, gaussdb-nodejs-protocol, gaussdb-nodejs-cursor,
and gaussdb-nodejs-query-stream. The pool package is version 0.2.5;
the other companion packages are version 0.2.3.
gaussdb-cloudflare remains the existing optional package.
Full database CI passes on Node.js 14, 15, 16, 18, 20, 22, 23 and 24. Package loading and SHA256 authentication calculation have additionally been checked on every major version from 14 through 26; this does not constitute full database integration testing on the additional versions.
sha256Iterations 用于设置客户端进行 SHA256 密码认证计算时的迭代次数。
| 配置 | 含义 |
|---|---|
| 不配置 | 当前 0.2.3 默认使用 2048 次 |
sha256Iterations: 'server' |
使用服务端在本次认证报文中下发的迭代次数 |
sha256Iterations: 10000 |
显式使用 10000 次;可指定 1 到 10000000 之间的整数 |
在 Client 或 Pool 的连接配置中加入该参数:
const { Client } = require('gaussdb-nodejs')
const client = new Client({
host: process.env.GAUSSHOST,
port: Number(process.env.GAUSSPORT || 8000),
user: process.env.GAUSSUSER,
password: process.env.GAUSSPASSWORD,
database: process.env.GAUSSDATABASE,
sha256Iterations: 'server',
})通过 npm 别名安装的项目可继续使用 require('gaussdb-node')。
登录目标数据库后执行以下 SQL,查看当前服务端配置:
SHOW auth_iteration_count;例如返回 10000,表示当前配置为 10000 次。
要查看本次连接实际下发的次数,可检查 SHA256 认证报文。
在当前这种 80 字节认证数据中,最后 4 字节为大端整数:
例如 AUTH ... hex= 末尾的 00002710,换算为十进制是 10000。
sha256Iterations: 'server' 直接使用这个报文值,无需手动换算或填写次数。
SHOW 展示的是当前配置,认证报文展示的是本次连接下发的值,应区分两者。
此参数只影响客户端计算,不会查询或修改服务端配置。
Each package in this repo should have its own readme more focused on how to develop/contribute.
The source repo for the documentation is available for contribution here.
- Connection pooling
- Extensible JS ↔ GaussDB data-type coercion
- Supported GaussDB features
- Parameterized queries
- Named statements with query plan caching
- Bulk import & export with
COPY TO/COPY FROM
gaussdb-node is by design pretty light on abstractions. These are some handy modules we've been using over the years to complete the picture.
gaussdb-node is free software. If you encounter a bug with the library please open an issue on the GitHub repo. If you have questions unanswered by the documentation please open an issue pointing out how the documentation was unclear & I will do my best to make it better!
When you open an issue please provide:
- version of Node
- version of GaussDB
- smallest possible snippet of code to reproduce the problem
❤️ contributions!
I will happily accept your pull request if it:
- has tests
- looks reasonable
- does not break backwards compatibility
If your change involves breaking backwards compatibility please please point that out in the pull request & we can discuss & plan when and how to release it and what type of documentation or communication it will require.
- Clone the repo
- From your workspace root run
yarnand thenyarn lerna bootstrap - Ensure you have a GaussDB instance running with SSL enabled and an empty database for tests
- Ensure you have the proper environment variables configured for connecting to the instance
- Run
yarn testto run all the tests
Copyright (c) 2010-2020 Brian Carlson (brian.m.carlson@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.