尝试使用Python SQLAlchemy在Denodo中执行查询时出错

2024-05-23 19:22:24 发布

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

我正在尝试使用Python和sqlalchemy库从Denodo获得一个表。这是我的密码

from sqlalchemy import create_engine
import os

sql = """SELECT * FROM test_table LIMIT 10 """
engine = create_engine('mssql+pyodbc://DenodoODBC', encoding='utf-8')

con = engine.connect().connection
cursor = con.cursor()
cursor.execute(sql)

df = cursor.fetchall()

cursor.close()
con.close()

当我第一次尝试运行它时,我得到以下错误。你知道吗

DBAPIError: (pyodbc.Error) (' \x10#', "[ \x10#] ERROR: Function 'schema_name' with arity 0 not found\njava.sql.SQLException: Function 'schema_name' with arity 0 not found;\nError while executing the query (7) (SQLExecDirectW)") [SQL: SELECT schema_name()]

我认为问题可能出在create\u engine上,因为当我第二次尝试运行代码而没有再次创建引擎时,一切都很好。你知道吗

我希望有人能向我解释发生了什么事。谢谢:)


Tags: nameimportclosesqlsqlalchemyschemacreatewith