4

I have problem executing SQL HANA query in Python. I established connection (in R I am able to connect to this HANA data table and it's working perfectly) but in Python I receive syntax error related to query -> I searched multiple sources how to deal with this query 'SELECT TOP 10 * FROM _SYS.TEMP_VALIDATION_09/TEMP_123' but I did not find answer. In R it looks like this ' SELECT TOP 10 * FROM "_SYS"."TEMP_VALIDATION_09/TEMP_123" '

from hdbcli import dbapi

#Initialize your connection
conn = dbapi.connect(address = '',
              port = , 
              user = '', 
              password = '')
​
print('connected')

cursor = conn.cursor()

query = 'SELECT TOP 10 * FROM _SYS.TEMP_VALIDATION_09/TEMP_123'
print(query)

result = cursor.execute(query)
for result in cursor:
    print(result)
2
  • Does this answer your question? sap hana - select top expression Commented Nov 20, 2019 at 10:59
  • 1
    have you tried to use double quotes around the table name like query = 'SELECT TOP 10 * FROM _SYS."TEMP_VALIDATION_09/TEMP_123"' Commented Nov 21, 2019 at 11:39

1 Answer 1

1

I did find the answer. It's related how identifiers are treated

There are two types Quotation mark for delimit: Single Quotation Mark (' ') – It is used to delimit the string. Double Quotation Mark (" ") – It is used for delimiting identifiers.

The solution:

query = ' SELECT TOP 10 * FROM "_SYS"."TEMP_VALIDATION_09/TEMP_123" '
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.