简体   繁体   English

pyodbc MERGE INTO 错误:HY000:驱动程序未提供错误

[英]pyodbc MERGE INTO error: HY000: The driver did not supply an error

I'm trying to execute many (~1000) MERGE INTO statements into oracledb 11.2.0.4.0(64bit) using python 3.9.2(64bit) and pyodbc 4.0.30(64bit).我正在尝试使用 python 3.9.2(64bit) 和 pyodbc 4.0.30(64bit) 在 oracledb 11.2.0.4.0(64bit) 中执行许多 (~1000) MERGE INTO 语句。 However, all the statements return an exception:但是,所有语句都返回异常:

HY000: The driver did not supply an error HY000:驱动程序未提供错误

I've tried everything I can think of to solve this problem, but no luck.我已经尝试了我能想到的一切来解决这个问题,但没有运气。 I tried changing code, encodings/decodings and ODBC driver from oracle home 12.1(64bit) to oracle home 19.1(64bit).我尝试将代码、编码/解码和 ODBC 驱动程序从 oracle 家庭 12.1(64 位)更改为 oracle 家庭 19.1。 I also tried using pyodbc 4.0.22 in which case the error just changed into:我也尝试使用 pyodbc 4.0.22 在这种情况下,错误刚刚变为:

<class 'pyodbc.ProgrammingError'> returned a result with an error set <class 'pyodbc.ProgrammingError'> 返回带有错误集的结果

Which is not any more helpful error than the first one.这并不比第一个错误更有帮助。 The issue I assume cannot be the MERGE INTO statement itself, because when I try running them directly in the database shell, it completes without issue.我假设的问题不能是 MERGE INTO 语句本身,因为当我尝试直接在数据库 shell 中运行它们时,它可以毫无问题地完成。

Below is my code.下面是我的代码。 I guess I should also mention the commands and parameters are read from stdin before being executed, and oracledb is using utf8 characterset.我想我还应该提到在执行之前从标准输入读取命令和参数,并且 oracledb 使用的是 utf8 字符集。

cmds = sys.stdin.readlines()
comms = json.loads(cmds[0])
conn = pyodbc.connect(connstring)
conn.setencoding(encoding="utf-8")

cursor = conn.cursor()
cursor.execute("""ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD"T"HH24:MI:SS.....'""")

for comm in comms:
  params = [(None) if str(x)=='None' or str(x)=='NULL' else (x) for x in comm["params"]]
  try:
    cursor.execute(comm["sql"],params)
  except Exception as e:
    print(e)

conn.commit()
conn.close()

Edit: Another things worth mentioning for sure - this issue began after python2.7 to 3.9.2 update.编辑:另一件值得一提的事情 - 这个问题在 python2.7 到 3.9.2 更新之后开始。 The code itself didn't require any changes at all in this particular location, though.不过,代码本身根本不需要在这个特定位置进行任何更改。

I've had my share of HY000 errors in the past.我过去曾遇到过 HY000 错误。 It almost always came down to a syntax error in the SQL query.它几乎总是归结为 SQL 查询中的语法错误。 Double check all your double and single quotes, and makes sure the query works when run independently in an SQL session to your database.仔细检查所有双引号和单引号,并确保查询在 SQL session 中独立运行到您的数据库时有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pyodbc.Error:(&#39;HY000&#39;,&#39;驱动程序未提供错误!&#39;) - pyodbc.Error: ('HY000', 'The driver did not supply an error!') 为什么我收到错误 pyodbc.Error: (&#39;HY000&#39;, &#39;驱动程序没有提供错误!&#39;) - Why I receive error pyodbc.Error: ('HY000', 'The driver did not supply an error!') Python SQLAlchemy pyodbc.Error: (&#39;HY000&#39;, &#39;驱动程序没有提供错误!&#39;) - Python SQLAlchemy pyodbc.Error: ('HY000', 'The driver did not supply an error!') Netsuite ODBC错误:pyodbc execute正在引发`[HY000]目录名称无效。”错误 - Netsuite ODBC Error: pyodbc execute is raising `[HY000] The directory name is invalid.` error Pyodbc 错误“TVP 的行必须是序列对象。”,'HY000' - Pyodbc Error "A TVP's rows must be Sequence objects.", 'HY000' 为什么我的查询出现HY000 pyodbc错误? - why do I get HY000 pyodbc error for my query? TypeError: ('Params must be in a list, tuple, or Row', 'HY000') pyodbc 错误 - TypeError: (‘Params must be in a list, tuple, or Row’, ‘HY000’) Error on pyodbc pyodbc.Error:('HY000','[HY000][Microsoft][ODBCDriver18forSQL Server]SSPIProvider:NoKerberoscredentialsavailable(默认缓存:FILE:/tmp/krb5cc_1051) - pyodbc.Error:('HY000','[HY000][Microsoft][ODBCDriver18forSQL Server]SSPIProvider:NoKerberoscredentialsavailable(default cache: FILE:/tmp/krb5cc_1051) mysql 错误:错误 1018 (HY000):无法读取 '.' 的目录 (错误号:13) - mysql error : ERROR 1018 (HY000): Can't read dir of '.' (errno: 13) DatabaseError: (&#39;HY000&#39;, &#39;[HY000] [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt (0) (SQLExecDirectW)&#39;) - DatabaseError: ('HY000', '[HY000] [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt (0) (SQLExecDirectW)')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM