Python Forum
Key error when using adodbapi, azure and pandas
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Key error when using adodbapi, azure and pandas

I'm using Anaconda environment (Spyder) for my Python development and until recently have been using adodbapi to connect to an Azure SQL server (namely because that one does not need an ODBC driver installed). With the established connection, I have been able to read stuff directly to a Pandas dataframe with pd.read_sql(), awesome.

I just updated everything in my Anaconda environment so I don't exactly know what caused the issue, but now using the exact same code as before leads to a key error (the last rows of the generated output below):

Traceback (most recent call last): File "<ipython-input-20-df4577e99893>", line 1, in <module> data = pd.read_sql(dataSQL, connection) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\", line 380, in read_sql chunksize=chunksize) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\", line 1482, in read_query parse_dates=parse_dates) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\", line 141, in _wrap_result coerce_float=coerce_float) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\", line 1512, in from_records coerce_float=coerce_float) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\internals\", line 408, in to_arrays elif isinstance(data[0], ABCSeries): File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\dtypes\", line 9, in _check return getattr(inst, attr, '_typ') in comp File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\adodbapi\", line 466, in __getattr__ return self._getValue(self.rows.columnNames[name.lower()]) KeyError: '_typ'
The code is simply:

import pandas as pd
import adodbapi

connection = adodbapi.connect("PROVIDER=SQLOLEDB; Data Source={0}; \
                              Database={1}; trusted_connection=no; \
                              Uid={2}; PWD={3};".format(server, database, username, password))

df = pd.read_sql(dataSQL, connection)
with string values assigned to the variables, and a legit SQL query as string in dataSQL. I have little to no understanding what is happening under the hood in these libraries, so any help is appreciated. What could be causing that key error? I am yet to try this with another connection type (have to wait for the IT to install the ODBC driver), but this connection method is widely used in my various code snippets and I would like to get it working again.
Did you find a solution?
I have the same issue with adodbapi after updating pandas
Hi, I found a solution. It's described there: adodbapi-patch suggestion at github

Since adodbapi doesn't change much, this simple "patch" will last long.

Possibly Related Threads…
Thread Author Replies Views Last Post
  strange error from pandas dataframe djf123 1 2,406 Jul-27-2020, 05:25 AM
Last Post: scidam
  error bars with dataframe and pandas Hucky 4 2,154 Apr-27-2020, 02:02 AM
Last Post: Hucky
  pip install pandas ERROR pythondudu 6 16,054 Mar-26-2020, 07:49 PM
Last Post: snippsat
  pandas error Scott 2 4,197 Feb-05-2020, 07:22 PM
Last Post: Scott
  pandas DataReader error on all data sources glidecode 5 14,289 Sep-25-2019, 02:10 PM
Last Post: perfringo
  pandas install error loren41 5 2,977 May-20-2019, 06:42 PM
Last Post: loren41
  utf-8 error with pandas read_csv logues 0 2,731 Oct-23-2018, 05:25 PM
Last Post: logues
  Using pandas, index error fyec 1 3,240 Aug-01-2018, 09:25 AM
Last Post: volcano63
  Error: Slicing a single date from Pandas cheerful 0 1,641 Jul-22-2018, 08:09 PM
Last Post: cheerful

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020