How do I found out the Host/Port when connecting to SAP HANA using python PyHDB

穿精又带淫゛_ 提交于 2021-02-11 16:40:38

问题


I'm trying to connect to a SAP HANA database, but I don't know where to find the host or port attributes for pyhdb.connect()

Test Code Below

import pyhdb

connection = pyhdb.connect(
    host="",
    port="",
    user="exampleusername",
    password="examplepassword"
)

cursor = connection.cursor()
cursor.execute("SELECT 'Hello Python World'")
cursor.fetchone()

connection.close()

Can someone please point me in the right direction?


回答1:


HOST,PORT and DATABASENAME are part of the SAP HANA logon information, forming the logical address of the database.

There is no way to "find out" the values for those parameters if you don't control the database except for that somebody who does, tells you.

The HOST in this scenario is the network host address for the system where the HANA database runs on. PORT depends on the actual installation of the database system and DATABASENAME is the logical name of the database, again something that can be freely chosen by the database administrator.

Using the SAP HANA Express Edition Virtual Machine as an example: HOST would be hxehost (or the IP address that the VM is reachable at).
PORT is 39015 following the 3xx15 pattern where xx is the instance number of the system, 90 in this instance.
DATABASENAME finally is HXE (HANA Express Edition).



来源:https://stackoverflow.com/questions/60759226/how-do-i-found-out-the-host-port-when-connecting-to-sap-hana-using-python-pyhdb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!