Error connecting HANA with Python, SQL syntax error:
Error connecting HANA with Python, SQL syntax error:
从 Python 连接到 hanna sap 数据库时出现错误,下面是 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()
问题是:
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
正如评论中已经提到的,您似乎混淆了双引号和单引号。
试试这个:
sql='SELECT T0."firstName" FROM "OHEM".T0'
从 Python 连接到 hanna sap 数据库时出现错误,下面是 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()
问题是:
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
正如评论中已经提到的,您似乎混淆了双引号和单引号。
试试这个:
sql='SELECT T0."firstName" FROM "OHEM".T0'