I put most of the details on how this was done on the small site I setup for my LLC (ZBasisADM Consulting) --> http://www.zbasisconsulting.com/PyHDB1
Most of what I did was update my previous scripts to make use of the HDB Python module available on GitHub --> https://github.com/SAP/PyHDB
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....: mk_tables.py
# 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(
host="54.226.200.xxx",
port=30015,
user="hanauser",
password="xxxxx"
)
# 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:
Post a Comment