大多数关于SAP和Python的教程告诉您,您需要SAP客户端才能从Python中与SAP进行交互。
例如:
所以在一段时间前它似乎是需要的。
但是,当您尝试安装SAP客户端时,您会意识到它不再可用。
那么,SAP客户端替代的是什么呢?
发布于 2016-02-01 16:44:08
安装API 比赫德。
该链接包含有关如何安装pyhdb以及如何使用它的说明。塞勒斯。
请注意,该示例假定为auto-commit = true
要安装的命令:
sudo apt-get install python-pip
sudo pip install pyhdb示例(自动提交= true):
import pyhdb
connection = pyhdb.connect(
host="example.com",
port=30015,
user="user",
password="secret"
)
cursor = connection.cursor()
cursor.execute("SELECT 'Hello Python World' FROM DUMMY")
cursor.fetchone()
connection.close()发布于 2017-08-30 00:13:08
参考资料:https://github.com/SAP/PyHDB
需要尝试的其他查询
## imports
import pandas as pd
import pprint
## Querying a systems table
cursor.execute('SELECT * FROM "PUBLIC"."M_CS_TABLES" LIMIT 10')
pd.DataFrame(cursor.fetchall())
## Creating a table:
cursor.execute('CREATE TABLE PYHDB_TEST("NAMES" VARCHAR (255) null)')
## Inserting a row to the table:
cursor.execute("INSERT INTO PYHDB_TEST VALUES('Testing python
client')")
pprint.pprint(cursor.rowcount)https://stackoverflow.com/questions/35135741
复制相似问题