Skip to Content
Author's profile photo Former Member

A hello-world HANA web application using

If you are looking to start building web apps with HANA on the backend quickly using Python, this is the right blog for you! For this, you need to have the following set up:

Once you have your environment ready, you can try the tutorial out. I found the module easy to use for the purpose of simple webpage-rendering. The tutorial can be found here: This tutorial will also help you get accustomed to the framework features. Basically, all you need to to do is:

  • Copy and past some boiler plate syntax in to your home directory
  • Import all the necessary libraries for Python (we will be using the pyodbc module in this example)
  • Set the template rendering path
  • Set the routes
  • Initialise DB connections and create a cursor
  • Define the classes (as pages) and methods (as actions)
  • Fire up the built in server and visit the page you just created

In the end your code should look something like this:

import web

import pyodbc


# ask template engine to render html files from the templates/ directory

render = web.template.render(‘templates/’)

# set url handler

urls = (

    ‘/’, ‘index’


# create a remote hana db connection through odbc

conn = pyodbc.connect(‘DSN=<odbc_connection_name>;UID=<user>;PWD=<password>’)

# create a cursor for executing queries

c = conn.cursor() #mysql cursor

# render views for index page

class index:

    def GET(self):

        c.execute(“SELECT * FROM <schema>.<table> ORDER BY <field>”) # hanadb execution

        todos = c.fetchall()

        return render.index(todos) # render the index files forwarding the todo parameter

# boiler plate syntax for running the main method

if __name__ == “__main__”:

    app = web.application(urls, globals())

Make sure you have followed and understood the tutorial before you jump into this piece of code. I saved this code in a file called

I created a simple index template which looks like this (/render/index.html):

$def with (todos)


$for todo in todos:

                    <li id=”$todo[0]”>$todo[1]</li>


This template file just renders the views to show you a list of results it passed through the todo variable.

Now to try it out:

C:\Users\UserName\Document\webpy> python


Check your browser to see if the page is visible or not by visiting http://localhost:8080. You should get a simple webpage with your records from HANA.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Kristian Rink
      Kristian Rink

      Voted it up a bit. Not an in-depth article after all, but it's definitely worth reading in order to get things "together" and get started. And it gives a bit of exposure, which definitely is a good thing. 🙂