Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Srdjan
Product and Topic Expert
Product and Topic Expert

Step by step example how to connect to SAP HANA Trial instance using Python or nodejs open source client, PyHDB or node-hdb and HANA Cloud Platform Console Client.

1. Download the SDK

To connect to hanatrial instance you need the command line client, from SAP HANA Cloud Platform Tools. If not already installed within your eclipse installation, download the SDK of choice from SAP Development Tools for Eclipse repository.

Unpack, start the bash shell on Linux or OSX, or Command Prompt on Windows and go to tools subfolder of the SDK. This example is tested on Linux (Ubuntu 14.04), on Windows should work the same way.

2. If you are behind a proxy, configure the proxy in your shell

following the readme.txt in tools folder.

3. Open the tunnel to hanatrial instance

following SAP HANA Cloud documentation,  like for example:

Username, account name and HANA instance name you may check in hanatrial Cockpit

After entering the password, the tunnel is opened and the localhost proxy created, for hanatrial instance access:

The default local port is 30015 but check if different.

4. Connect from Python or nodejs Client

Use displayed parameters to connect from Python client and display table names for example:

import pyhdb

connection = pyhdb.connect('localhost', 30015, 'DEV_4C55S55VRW5Z1W3STRMBCWLE0', 'Gy5q95tQaGnOZbz')

cursor = connection.cursor()

cursor.execute('select * from tables')

tables = cursor.fetchall()

for table in tables:

    print table[1]

It works the same way for nodejs client, only connection parameters adapted from node-hdb Getting Started example:

var hdb    = require('hdb');

var client = hdb.createClient({

  host    : 'localhost',

  port    : 30015,

  user    : 'DEV_4C55S55VRW5Z1W3STRMBCWLE0',

  password : 'Gy5q95tQaGnOZbz'

});

client.on('error', function (err) {

  console.error('Network connection error', err);

});

client.connect(function (err) {

  if (err) {

    return console.error('Connect error', err);

  }

  client.exec('select * from DUMMY', function (err, rows) {

    client.end();

    if (err) {

      return console.error('Execute error:', err);

    }

    console.log('Results:', rows);

  });

});

2 Comments