cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

HANA Calculated view query using Python

Former Member
0 Likes
2,436

Python

I am currently trying to access a calculated view on HANA through python using hdbcli library.

I have no problems with connecting, but when trying to query information it doesn't work.

My calculated view is hosted in a path such as this:

And I'm using this code to query:

from hdbcli import dbapi
conn = dbapi(connect(host,port,user,password)
query = "select * from HANA1.MAIN.OrdersReview.CV_Inbound_Orders"
cursor = conn.cursor()
try:
  res = cursor.execute(query)
  res = cursor.fetchall()
exception:
  print("Something went wrong")
conn.close()
cursor.close()

I think the problem is in the query string but haven't find what it is... any ideas?

View Entire Topic
michael_eaton3
Active Contributor

Hello

I would recommend that you use the data preview feature in the HANA Studio to obtain sample SQL.

To reference a calculation view you'll require a schema name, and quotes around the schema name and package/view reference, for example.

SELECT blah FROM "_SYS_BIC"."Package1.Package2.PushdownPoC/CA_WITH_STUFF"

Michael

Former Member

Hello Michael

Thank you! It worked perfectly.

I include the query string, just in case, anyone has the same issue:

query='select top 10 * from \"_SYS_BIC\".\"Package1.Package2.PushdownPoC/CA_WITH_STUFF\"'