Feb-15-2019, 01:29 PM
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):
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.