python连接hana数据库

跟连普通的数据库差别不大

import pyhdb

def get_connection():
    conn_obj = pyhdb.connect(
        host = "10.16.29.131", #HANA地址
        port = 30015, #HANA端口号
        user = "20140006", #用户号
        password = "******" #密码
    )
    return conn_obj

def get_mat(conn):
    cursor = conn.cursor()
    cursor.execute('SELECT * FROM "20140006"."Z_MAT_CABNT"')      #连接表和视图都可以
    mat = cursor.fetchall()
    return mat

conn = get_connection()
mats = get_mat(conn)
for i in mats:
    print(i)

猜你喜欢

转载自blog.csdn.net/bxy5511/article/details/81476546