0

I have an error when connecting to the hanna sap database from Python, below is the code from sap.py

import pyhdb
import hana_ml
import hana_ml.dataframe as dataframe
# Instantiate connection object
conn = dataframe.ConnectionContext("xxx.xxx.xx.x.", 30015, "der", "qwertt")

sql="SELECT T0.'firstName' FROM 'OHEM'.T0"

df_pushdown = conn.sql(sql)
print(df_pushdown.collect())

# Close connection
conn.close()

The problem is:

py sap.py
(257, 'sql syntax error: incorrect syntax near "firstName": line 1 col 11 (at pos 11)')
Failed to retrieve data for the current dataframe, (257, 'sql syntax error: incorrect syntax near "firstName": line 1 col 11 (at pos 11)')
Traceback (most recent call last):
  File "C:\Users\jmoreira\Desktop\Proyectos\peso\sap.py", line 13, in <module>
    print(df_pushdown.collect())
  File "C:\Users\jmoreira\AppData\Local\Programs\Python\Python310\lib\site-packages\hana_ml\dataframe.py", line 2990, in collect   
2
  • 2
    There's something wrong with your sql code, this isn't really a python issue. Commented Apr 27, 2022 at 17:03
  • 1
    I am not sure about HANA, but usually notation is 'string' and "column". So Try SELECT T0."firstName" FROM "OHEM".T0 Commented Apr 28, 2022 at 7:16

1 Answer 1

1

As already mentioned in the comments, it seems you mixed up double and single quotes.

Try this:

sql='SELECT T0."firstName" FROM "OHEM".T0'
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.