gpt4 book ai didi

Python SQLAlchemy pyodbc.错误 : ('HY000' , 'The driver did not supply an error!' )

转载 作者:太空宇宙 更新时间:2023-11-04 02:24:47 32 4
gpt4 key购买 nike

大家好,我现在正在使用 Pandas 和 MSSQL。我一直工作正常,但最近在 SQlalchemy 更新后,当我尝试通过 df.to_sql 将信息上传到数据库时出现以下错误

pyodbc.Error: ('HY000', '驱动程序没有提供错误!')

我的连接定义如下

engine = create_engine('mssql+pyodbc://Reporter:******@localhost:1433/SourcingDb?driver=SQL+Server')

df.to_sql('ProductivityDeck', con=engine, if_exists='replace', index= False)

我得到的完整错误是这个

Traceback (most recent call last):

文件“C:\Python\Python36\lib\site-packages\sqlalchemy\engine\base.py”,第 1182 行,在 _execute_context 中 语境) 文件“C:\Python\Python36\lib\site-packages\sqlalchemy\engine\default.py”,第 470 行,在 do_execute 中 cursor.execute(语句,参数)pyodbc.Error: ('HY000', '驱动程序没有提供错误!')

上面的异常是下面异常的直接原因:

Traceback (most recent call last):
File "C:/Users/H212310/PycharmProjects/untitled2/UpdateCEDeckv2.py", line 23, in <module>
df.to_sql('ProductivityDeck', con=engine, if_exists='replace', index= False)
File "C:\Python\Python36\lib\site-packages\pandas\core\generic.py", line 2127, in to_sql
dtype=dtype)
File "C:\Python\Python36\lib\site-packages\pandas\io\sql.py", line 450, in to_sql
chunksize=chunksize, dtype=dtype)
File "C:\Python\Python36\lib\site-packages\pandas\io\sql.py", line 1149, in to_sql
table.insert(chunksize)
File "C:\Python\Python36\lib\site-packages\pandas\io\sql.py", line 663, in insert
self._execute_insert(conn, keys, chunk_iter)
File "C:\Python\Python36\lib\site-packages\pandas\io\sql.py", line 638, in _execute_insert
conn.execute(*self.insert_statement(data, conn))
File "C:\Python\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 945, in execute
return meth(self, multiparams, params)
File "C:\Python\Python36\lib\site-packages\sqlalchemy\sql\elements.py", line 263, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "C:\Python\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1053, in _execute_clauseelement
compiled_sql, distilled_params
File "C:\Python\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1189, in _execute_context
context)
File "C:\Python\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1402, in _handle_dbapi_exception
exc_info
File "C:\Python\Python36\lib\site-packages\sqlalchemy\util\compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "C:\Python\Python36\lib\site-packages\sqlalchemy\util\compat.py", line 186, in reraise
raise value.with_traceback(tb)
File "C:\Python\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1182, in _execute_context context)
File "C:\Python\Python36\lib\site-packages\sqlalchemy\engine\default.py", line 470, in do_execute
cursor.execute(statement, parameters)

我尝试回滚到较低版本的 SqlAlchemy,在 Windows 中更新 ODBC 驱动程序并升级 python 安装,但它一直在出现。

关于如何解决这个问题有什么想法吗?

最佳答案

好的,这是“pandas 23 中已知错误的静默错误,降级到 v22 会使错误消失,您可以上传 1000 多行。”

这正在制定中

https://github.com/pandas-dev/pandas/issues/21103

关于Python SQLAlchemy pyodbc.错误 : ('HY000' , 'The driver did not supply an error!' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50688468/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com