The SQream DB Node.JS driver allows Javascript applications and tools connect to SQream DB. This tutorial shows you how to write a Node application using the Node.JS interface.

The driver requires Node 10 or newer.

Installing the Node.JS driver


  • Node.JS 10 or newer. Follow instructions at .

Getting the tarball

The Node driver is provided as a tarball for download from the SQream Drivers page .

Install with NPM

$ sudo npm install sqreamdb-3.0.0.tgz

Connect to SQream DB with a Node.JS application

Create a simple test

Replace the connection parameters with real parameters for a SQream DB installation.

const Connection  = require('sqreamdb');
const config  =  {
  host: '<host>',
  port: <port>,
  username: '<username>',
  password: '<password>',
  connectDatabase: '<database>',
  cluster: '<true | false>',
  ssl: '<true | false>',
  service: '<workload manager service>'

const query1  =  'SELECT 1 AS test, 2*6 AS "dozen"';

const myConnection  = new Connection(config);
myConnection.runQuery(query1, function  (err, data){
   console.log(err, data);

Run the test

A successful run should look like this:

$ node sqreamdb-test.js
null [  { test: 1, dozen: 12  }  ]

API reference

Connection parameters

Item Optional Default Description
host None Hostname for SQream DB worker. For example,,
port None Port for SQream DB end-point. For example, 3108 for the load balancer, 5000 for a worker.
username None Username of a role to use for connection. For example, rhendricks
password None Specifies the password of the selected role. For example, Tr0ub4dor&3
connectDatabase None Database name to connect to. For example, master
service sqream Specifices service queue to use. For example, etl
ssl false Specifies SSL for this connection. For example, true
cluster false Connect via load balancer (use only if exists, and check port). For example, true


The connector handles event returns with an event emitter

The getConnectionId event returns the executing connection ID.
The getStatementId event returns the executing statement ID.
The getTypes event returns the results columns types.


const myConnection  = new Connection(config);

myConnection.runQuery(query1, function  (err, data){'getConnectionId', function(data){
      console.log('getConnectionId', data);
  });'getStatementId', function(data){
      console.log('getStatementId', data);
  });'getTypes', function(data){
      console.log('getTypes', data);

Setting flags

SQream DB configuration flags can be set per statement, as a parameter to runQuery.

For example:

const setFlag  =  'SET showfullexceptioninfo = true;';

const query_string = 'SELECT 1';

const myConnection  = new Connection(config);
myConnection.runQuery(query_string, function  (err, data){
  console.log(err, data);
}, setFlag);