如何在visualstudi中正确安装pyhdb

2024-06-16 08:28:54 发布

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

我正在Visual Studio中使用pyhdb设置与SAP数据库的连接,无法访问pyhdb模块

使用visualstudio2019,python3.72,安装了pyhdb(0.3.4)包

import pyhdb

def hana_cursor(system):
    connection = pyhdb.connect(
        host="10.200.81.10",
        port=port[system],
        user="USER",
        password="PASS"
    )

    return connection.cursor()

def get_SP(item):
    cursor = hana_cursor("server1")
    cursor.execute(f"select SP from SAPDB where ID='{item}'")

    data = cursor.fetchone()
    return data

get_SP(1000)

应为:从SAPDB返回ID为1000的SP属性

取而代之的是:

    connection = pyhdb.connect(
AttributeError: module 'pyhdb' has no attribute 'connect'

Friend在Pycharm中运行完全相同的代码并得到所需的结果。 好像软件包有问题,我是通过VS软件包安装的


Tags: iddatagetreturnportdefconnectconnection