问题
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