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
#1
Hi!

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):

Output:
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\sql.py", line 380, in read_sql chunksize=chunksize) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py", line 1482, in read_query parse_dates=parse_dates) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py", line 141, in _wrap_result coerce_float=coerce_float) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\frame.py", line 1512, in from_records coerce_float=coerce_float) File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\internals\construction.py", line 408, in to_arrays elif isinstance(data[0], ABCSeries): File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\dtypes\generic.py", line 9, in _check return getattr(inst, attr, '_typ') in comp File "C:\Users\mahal\AppData\Local\Continuum\anaconda3\lib\site-packages\adodbapi\apibase.py", 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.
Reply
#2
Did you find a solution?
I have the same issue with adodbapi after updating pandas
Reply
#3
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.
Reply


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

Forum Jump:

User Panel Messages

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