Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fjakobs/databricks-sql-nodejs

 
 

Repository files navigation

Databricks SQL Driver for NodeJS (Beta)

http://www.apache.org/licenses/LICENSE-2.0.txt npm test coverage

Description

The Databricks SQL Driver for NodeJS is a Javascript driver for applications that connect to Databricks clusters and SQL warehouses. This project is a fork of Hive Driver which connects via Thrift API.

NOTE: This Driver is Beta.

Documentation

For detailed documentation and usage examples, read the Getting Started guide.

Requirements

  • Node.js 14 or newer

Installation

npm i @databricks/sql

Usage

examples/usage.js

const { DBSQLClient } = require('@databricks/sql');

const client = new DBSQLClient();
const utils = DBSQLClient.utils;

client.connect({
    host: '********.databricks.com',
    path: '/sql/1.0/endpoints/****************',
    token: 'dapi********************************',
}).then(async client => {
    const session = await client.openSession();

    const queryOperation = await session.executeStatement('SELECT "Hello, World!"', { runAsync: true });
    await utils.waitUntilReady(queryOperation, false, () => {});
    await utils.fetchAll(queryOperation);
    await queryOperation.close();

    const result = utils.getResult(queryOperation).getValue();
    console.table(result);

    await session.close();
    client.close();
}).catch(error => {
    console.log(error);
});

Run Tests

Unit tests

npm run test

You can specify a specific test to run by changing package.json:

"scripts": {
    "test": "nyc --reporter=lcov mocha 'tests/unit/result/JsonResult.test.js'",
}

Or to run all unit tests:

"scripts": {
    "test": "nyc --reporter=lcov mocha 'tests/unit/**/*.test.js'",
}

e2e tests

Before running end-to-end tests, copy the sample configuration file into the repository root and set the Databricks SQL connection info:

{
    host: '***.databricks.com',
    path: '/sql/1.0/endpoints/***',
    token: 'dapi***',
    database: ['catalog', 'database'],
}

Then run

npm run e2e

Contributing

See CONTRIBUTING.md

Issues

If you find any issues, feel free to create an issue or send a pull request directly.

License

Apache License 2.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 44.5%
  • TypeScript 39.2%
  • Thrift 16.3%