不带HANA Clien的Python和SAP HANA

2024-04-23 18:38:23 发布

您现在位置:Python中文网/ 问答频道 /正文

关于SAP HANA和Python的大多数教程都告诉您,需要saphana客户机才能从Python与saphana交互。

例如

所以这似乎是一段时间前需要的。

但是,当您尝试安装SAP HANA客户端时,您会意识到它不再可用。

那么SAP HANA Client替代Python的是什么呢?


Tags: andofclient客户端客户机with教程yes
2条回答

引用: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)

安装API pyhdb

该链接包含有关如何安装pyhdb和如何使用pyhdb的说明。塞尔斯。

请注意,示例假设auto-commit = true

要安装的命令:

sudo apt-get install python-pip
sudo pip install pyhdb

示例(auto commit=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()

相关问题 更多 >