SAP 官方有关Python连接HANA数据库方式
https://developers.sap.com/tutorials/hana-clients-python.html
实例
#!/usr/bin/python3
# Import your dependencies
import platform
from hdbcli import dbapi
# verify the architecture of Python
print("Platform architecture: " + platform.architecture()[0])
# Initialize your connection
conn = dbapi.connect(
address='xx.xx.xx.xx',
port='xx',
user='xx',
password='xx',
currentschema='xx'
)
# If no errors, print connected
print('connected')
cursor = conn.cursor()
sql_command = '''
select * from xxxx
'''
cursor.execute(sql_command)
rows = cursor.fetchall()
for row in rows:
for col in row:
print("%s" % col, end=" ")
print(" ")
cursor.close()
print("\n")
cursor.close()
conn.close()