Skip to content

Simplify basic usage (hide Thrift details) #1

Description

@arikfr

Current basic usage example:

const driver = require('databricks-sql-node');
const { TCLIService, TCLIService_types } = driver.thrift;
const client = new driver.DBSQLClient(
    TCLIService,
    TCLIService_types
);

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

    console.log(response.getValue());

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

Let's simplify it to be:

const driver = require('databricks-sql-node');
const client = new driver.DBSQLClient();

await client.connect({
    host: '********.databricks.com',
    path: '/sql/1.0/endpoints/****************',
    token: 'dapi********************************',
});

const session = await client.openSession();
const response = await session.executeStatement("SELECT 1");

// TODO: probably need to change the following
console.log(response.getValue());

await session.close();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions