python连接SAP HANA 数据库

SAP 官方有关Python连接HANA数据库方式
https://developers.sap.com/tutorials/hana-clients-python.html

python连接SAP HANA 数据库_第1张图片
python连接SAP HANA 数据库_第2张图片

实例

#!/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()


你可能感兴趣的:(Python,python,数据库)