'Error connecting HANA with Python, SQL syntax error:
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
Solution 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'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mathias Kemeter |
