Reputation: 90
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
Upvotes: 0
Views: 430
Reputation: 1193
As already mentioned in the comments, it seems you mixed up double and single quotes.
Try this:
sql='SELECT T0."firstName" FROM "OHEM".T0'
Upvotes: 1