A native, high-performance TypeScript reimplementation of the JustyBase.NetezzaDriver.
It allows for direct connection to IBM Netezza / PureData System for Analytics databases without the need for ODBC drivers or external dependencies.
- Pure TypeScript: No native bindings, no ODBC/CLI required.
- High Performance: Optimized for large result sets using internal buffer pooling.
- pg-style
query():connection.query()/pool.query()return bufferedQueryResult(rows,rowCount,fields). - ADO.NET Style API: Familiar Connection/Command/Reader pattern when you need streaming readers.
- Connection strings:
netezza:///nz://URIs viaparseConnectionStringornew NzConnection(uri). - Connection Pool: Built-in
NzPoolwith configurable limits, timeouts, and idle management. - Structured errors: Backend failures throw
NzDatabaseErrorwith SQLSTATE / severity / detail when present. - Security & Audit: SSL/TLS, MD5/SHA256 authentication, and Guardium audit metadata.
- Strongly Typed: Full TypeScript support; dual CJS + ESM builds.
npm install @justybase/netezza-driverRequires Node.js >= 18.18.0.
import { NzConnection } from '@justybase/netezza-driver';
async function example() {
// Object config or connection string
const connection = new NzConnection({
host: 'your-nz-host',
database: 'system',
user: 'admin',
password: 'password',
// port: 5480, // default
});
// const connection = new NzConnection('netezza://admin:password@your-nz-host:5480/system');
await connection.connect();
try {
const result = await connection.query(
'SELECT TABLENAME FROM _V_TABLE WHERE TABLENAME = $1 LIMIT 5',
['DIMDATE']
);
for (const row of result.rows) {
console.log(row.TABLENAME);
}
console.log('rowCount:', result.rowCount);
} finally {
connection.close();
}
}Netezza’s simple-query path used by this driver does not expose server-side bind/prepared parameters. $1, $2, … placeholders are escaped client-side and interpolated into the SQL text before send (escapeLiteral / substituteParameters). Prefer primitives (null, boolean, number, bigint, string, Date, Buffer); unsupported object shapes are rejected.
import { parseConnectionString, NzConnection } from '@justybase/netezza-driver';
const config = parseConnectionString(
'netezza://admin:secret@host:5480/JUST_DATA?sslmode=require&appName=myapp'
);
const connection = new NzConnection(config);
// or: new NzConnection('nz://admin:secret@host/JUST_DATA');Failed queries and authentication errors throw NzDatabaseError (extends Error) with optional severity, code (SQLSTATE), detail, hint, and raw payload fields.
import { NzDatabaseError } from '@justybase/netezza-driver';
try {
await connection.query('SELECT * FROM no_such_table');
} catch (err) {
if (err instanceof NzDatabaseError) {
console.error(err.code, err.message, err.detail);
}
throw err;
}import { NzPool } from '@justybase/netezza-driver';
const pool = new NzPool({
host: 'your-nz-host',
database: 'system',
user: 'admin',
password: 'password',
max: 10,
idleTimeoutMillis: 30000,
});
async function runQuery() {
const result = await pool.query('SELECT 1 AS n');
console.log(result.rows[0].n);
}When you need streaming readers, cancellation, or fine-grained command control, use Connection / Command / Reader:
import { NzConnection } from '@justybase/netezza-driver';
async function example() {
const connection = new NzConnection({
host: 'your-nz-host',
database: 'system',
user: 'admin',
password: 'password',
});
await connection.connect();
try {
const reader = await connection
.createCommand('SELECT TABLENAME FROM _V_TABLE ORDER BY TABLENAME LIMIT 5')
.executeReader();
try {
while (await reader.read()) {
console.log(`Found table: ${reader.getString(0)}`);
}
} finally {
await reader.close();
}
} finally {
connection.close();
}
}const connection = new NzConnection({
// ... basic connection info
appName: 'MyDataService',
osUser: 'service-account',
clientHostName: 'worker-node-1',
});This driver exposes both a pg-style buffered query() API and ADO.NET-inspired connection/command/reader abstractions. The design mirrors common C# database client patterns for streaming use cases.
Important: this project is an independent TypeScript implementation and does not reuse code from the node-netezza package. The functional and architectural inspiration comes from the C# implementation referenced above.
Note: The
node-netezzapackage is included for benchmarking, andodbcis included for testing compatibility.
Repository CI runs offline unit tests (npm run test:unit) on Node 22.x. Live Netezza smoke/full suites stay local. The published package engines field requires >=18.18.0.
| Variable | Purpose |
|---|---|
NZ_DEV_HOST |
Netezza host (required for integration tests unless lab defaults) |
NZ_DEV_PASSWORD |
Password (required unless lab defaults) |
NZ_DEV_PORT |
Port (default 5480) |
NZ_DEV_DATABASE |
Database (default JUST_DATA) |
NZ_DEV_USER |
User (default admin) |
NZ_USE_LAB_DEFAULTS |
Set to 1 to allow hardcoded lab defaults when host/password are unset |
NZ_SSL_CERT_PATH |
Optional trusted cert for SSL tests |
NZ_LOCAL_TMP_DIR |
Optional temp dir for external-table tests / examples |
See .env.example for a copy-paste template.
# Windows (PowerShell)
$env:NZ_DEV_HOST="192.168.0.144"
$env:NZ_DEV_PASSWORD="your_password"
# Linux/macOS
export NZ_DEV_HOST=192.168.0.144
export NZ_DEV_PASSWORD=your_passwordnpm run test:unitCovers SQL parameter escaping, NzDatabaseError parsing, and connection-string parsing. No database required.
Requires a live Netezza server and NZ_DEV_HOST + NZ_DEV_PASSWORD (or NZ_USE_LAB_DEFAULTS=1).
npm test
# or
npm run test:smokeSee LINUX_ODBC_FIX.md if ODBC comparison tests fail on Linux due to encoding issues in node-odbc.
npm run test:fullnpm run test:debug
npx jest tests/BasicTests.test.js --config jest.config.js --runInBandUse the public metadata methods on NzDataReader when you need server type information.
const reader = await connection
.createCommand(`
SELECT
'AA'::NVARCHAR(32) AS NVC,
CURRENT_DATE AS CD
FROM JUST_DATA..DIMACCOUNT
LIMIT 1
`)
.executeReader();
const metadata = reader.getColumnMetadata(0);
console.log(metadata.typeName); // NVARCHAR
console.log(metadata.declaredTypeName); // NVARCHAR(32)
console.log(metadata.providerType); // 2530For compatibility, getTypeName() continues to return canonical base names such as VARCHAR, NVARCHAR, NCHAR, DATE, and TIMESTAMPTZ. Use getDeclaredTypeName() or getColumnMetadata() when you also need declared lengths like VARCHAR(32).
Starting in 2.0.0, loose text-protocol queries and table-backed binary queries use the same JavaScript value contract whenever the server provides a known type OID.
The main mappings are BOOL -> boolean, BYTEINT/INT2/INT4/OID -> number, INT8 -> bigint, DATE/TIMESTAMP/TIMESTAMPTZ/ABSTIME -> Date, TIME -> TimeValue, and NUMERIC -> number | string using the existing precision-preserving rule.
npm run buildProduces dual packages under dist/cjs (CommonJS) and dist/esm (ES modules).
Optional API docs:
npm run docs