Reputation: 43
Hi Everyone I Am working right now with Pandas and MSSQL. I have bene working ok but recently after an SQlalchemy update i am getting the following error when I am trying to upload information into the DB via df.to_sql
pyodbc.Error: ('HY000', 'The driver did not supply an error!')
My connection is defined as follows
engine = create_engine('mssql+pyodbc://Reporter:******@localhost:1433/SourcingDb?driver=SQL+Server')
df.to_sql('ProductivityDeck', con=engine, if_exists='replace', index= False)
and the full error I get is this one
Traceback (most recent call last):
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) pyodbc.Error: ('HY000', 'The driver did not supply an error!')
The above exception was the direct cause of the following exception:
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)
I have tried to rollback to a lower version of SqlAlchemy, Update the ODBC driver in windows and upgrading the python installation and it keeps coming back.
Any ideas in how to fix this issue?
Upvotes: 2
Views: 8197
Reputation: 21
I wanted to supply my own experience with this error.
From one day to the next I went from the connection test working fine, to getting the same "Driver did not supply an error!" message.
I tried everything I could think of including uninstall / reinstall of all dependencies. Changing my connection string, testing if that was causing the issue.
What I found was the issue was that I was connecting to my organizations network via VPN. I went onsite and tested the connection and it worked. I can't explain why, but I can definitely single that out as the root cause.
Hope this helps spare someone hours of troubleshooting. Really unsatisfied with how vague of an error message pyodbc provides.
Upvotes: 0
Reputation: 353
pyodbc.connect('Driver={ODBC Driver 17 for SQL Server};')
Just changing the driver worked for me!!
Upvotes: 0
Reputation: 154
I had the same error ('HY000', 'The driver did not supply an error!'). The existing solutions on a few StackOverflow threads did not help.
In my case, the error came from pyodbc.connect()
.
I ended up reinstalling python and dependencies and the problem disappeared.
Upvotes: 0
Reputation: 43
OK this was a "silent error for a known bug in pandas 23, downgrading to v22 makes the error go away and you can upload 1000+ rows.
this is being worked out on
https://github.com/pandas-dev/pandas/issues/21103
Upvotes: 2