Wednesday, August 19, 2015

SAP HANA One - Pushing data into HANA using PyHDB

I put most of the details on how this was done on the small site I setup for my LLC  (ZBasisADM Consulting) -->

Most of what I did was update my previous scripts to make use of the HDB Python module available on GitHub -->

This module made loading very simple. Here is a quick example that shows setting up a connection ('conn'), opening a cursor object ('cur'), and then executing a statement.

# Name....:
# Author..: J. Haynes
# Purpose.: Create needed tables in HDB
# Pull in the needed libraries and setup the connection to the AWS instance
import pyhdb
conn = pyhdb.connect(
# Setup a cursor object
cur = conn.cursor()
# Create tables in HANA
cur.execute('CREATE TABLE F_STATS("SymId" INTEGER, "SymName" \
VARCHAR (10) null,"DateText" VARCHAR (20) null, "HeadLine" \
VARCHAR (30) null, "DataLine" VARCHAR (30) null)')

Nice and simple. This is a very quick very easy way to load data into HANA from a remote system.

In my other blog post, I provide examples of scripts that scrape information from web pages and then use that information to build larger sets of data.  

No comments: