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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@iqx-limited/sqlanywhere

v2.1.15

Published

SQL Anywhere JavaScript Driver.

Downloads

124

Readme

@iqx-limited/sqlanywhere

[!NOTE] This is a fork of the original driver sqlanywhere/node-sqlanywhere which has not had any updates for several years and was no longer working with newer versions of NodeJS.

A modern, high-performance Node.js driver for SAP SQL Anywhere.

This driver is built using N-API, ensuring a stable and future-proof interface that is independent of the underlying JavaScript engine. It is fully async/await compatible, providing a clean and modern developer experience.

[!CAUTION] This has only been tested in my environment and 1 set of specific databases - your mileage may vary

If you are running into issues, feel free to open an issue, however on the off chance that this does work for you - please let me know via discussions

NPM

Prerequisites

  • Node.js: Version 18.0.0 or higher.
  • SAP SQL Anywhere: The appropriate SQL Anywhere client libraries must be installed and correctly configured in your environment (e.g., via the $SQLANY environment variable and system path). - These can be downloaded from SAP Support
  • If compiling;
    • C++ Toolchain: A C++ compiler and build tools are required for the native addon compilation. This is typically handled by node-gyp. Please see the node-gyp installation guide for platform-specific instructions.

Installation

npm install @iqx-limited/sqlanywhere

The installation process will attempt to use pre-built binaries, if that fails, it will automatically compile the native C++ addon for your platform.

Getting Started

[!TIP] This package provides two entry points:

  • @iqx-limited/sqlanywhere: Exposes the original callback-based API.
  • @iqx-limited/sqlanywhere/promise: Exposes a fully promisified API, ideal for use with async/await.

All examples below use the /promise entry point for modern, promise-based usage. If you prefer callbacks, use the main package import instead.

const sqlanywhere = require('@iqx-limited/sqlanywhere/promise');

// --- For security, use environment variables for credentials ---
const connParams = {
  ServerName: process.env.DB_SERVER || 'demo',
  UserID: process.env.DB_USER || 'DBA',
  Password: process.env.DB_PASSWORD || 'sql'
};

async function main() {
  const connection = sqlanywhere.createConnection();

  try {
    // 1. Connect to the database
    console.log('Connecting...');
    await connection.connect(connParams);
    console.log('Connection successful!');

    // 2. Execute a query with parameters
    const products = await connection.exec(
      'SELECT Name, Description FROM Products WHERE id = ?',
      [301]
    );
    console.log('Query Result:', products[0]);
    // output --> Query Result: { Name: 'Tee Shirt', Description: 'V-neck' }

  } catch (error) {
    console.error('An error occurred:', error);
  } finally {
    // 3. Disconnect when finished
    console.log('Disconnecting...');
    await connection.disconnect();
    console.log('Disconnected.');
  }
}

main();

Connection

sqlanywhere.createConnection() Creates a new, uninitialized connection object.

connection.connect(params) Establishes a connection to the database. The params object can contain most valid SQL Anywhere connection properties.

connection.disconnect() or connection.close() Closes the database connection.

connection.exec(sql, [params]) Executes a SQL statement directly.

  • For SELECT queries, it returns a Promise that resolves to an array of result objects.
  • For DML statements (INSERT, UPDATE, DELETE), it returns a Promise that resolves to the number of affected rows.
  • Parameters can be bound using ? placeholders.

connection.prepare(sql) Prepares a SQL statement for later execution. Returns a Promise that resolves to a Statement object.

connection.commit() Commits the current transaction.

connection.rollback() Rolls back the current transaction.

Statement (from connection.prepare())

statement.exec([params]) Executes a prepared statement. The return value is the same as connection.exec().

statement.getMoreResults() For procedures or batches that return multiple result sets, this method advances to the next result set. Returns a Promise that resolves to the next array of results. When no more result sets are available, the promise will reject with a "Procedure has completed" message.

statement.drop() Frees the resources associated with the prepared statement on the database server.

Data Type Support

This driver provides comprehensive support for a wide range of SQL Anywhere data types, which are automatically mapped to the most appropriate JavaScript types:

| SQL Anywhere Type(s) | JavaScript Type | | ------------------------------------------------------------------------------------------ | --------------------------------------------- | | INTEGER, BIGINT, SMALLINT, TINYINT, DECIMAL, DOUBLE, FLOAT, BIT, etc. | number | | VARCHAR, CHAR, LONG NVARCHAR, DATE, TIME, TIMESTAMP, UNIQUEIDENTIFIER, XML | string | | BINARY, VARBINARY, LONG BINARY, ST_GEOMETRY | Buffer |

Debug Logging

// Import from the main package:
import { debugLogging } from '@iqx-limited/sqlanywhere';
// or: const { debugLogging } = require('@iqx-limited/sqlanywhere');

// Or import from the /promise entry point:
import { debugLogging } from '@iqx-limited/sqlanywhere/promise';
// or: const { debugLogging } = require('@iqx-limited/sqlanywhere/promise');

// Then set to true
debugLogging(true);

Running the Test Suite

The project includes a comprehensive test suite that validates all driver functionality against a live database.

  1. Configure Credentials: Copy the examples/.env.sample file to a new file named examples/.env and fill in your database connection details.

  2. Run Tests: Execute the following command from the examples directory:

    npm run test

Resources