Skip to content

Instantly share code, notes, and snippets.

@jasper07
Last active May 26, 2021 14:36
Show Gist options
  • Save jasper07/0c286f90d14ce995c31c06044d7c1ea3 to your computer and use it in GitHub Desktop.
Save jasper07/0c286f90d14ce995c31c06044d7c1ea3 to your computer and use it in GitHub Desktop.
SAP HANA Database Client for Node working with ES6 Async Await
'use strict';
var util = require('util');
var client = require('./client');
var fields = ['SCHEMA_NAME || \'.\' || TABLE_NAME as TABLE'];
var sql = util.format('select top 5 %s from TABLES', fields.join(','));
const connect = async () =>
await client.connect();
const executeAndfetchRows = async () =>
new Promise((resolve, reject) =>
client.exec(sql, (err, rows) => resolve(rows)));
const disconnect = async (rows) => {
await client.disconnect();
return rows;
}
const done = (rows) => {
console.log(util.inspect(rows, {
colors: true
}))
}
connect()
.then(executeAndfetchRows)
.then(disconnect)
.then(done);
@elyohan14
Copy link

Hello, ./client is it a file?

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