By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

Python not getting data from SQL Server

P: 1
I'm trying to fetch a table from MS SQL Server into Pandas but I get the error:

ProgrammingError: ('ODBC SQL type -151 is not yet supported. column-index=3 type=-151', 'HY106')

Expand|Select|Wrap|Line Numbers
  1. import pandas
  2. import pyodbc
  4. cnxn = pyodbc.connect("Driver={ODBC Driver 13 for SQL Server};"
  5.                       "Server=localhost;"
  6.                       "Database=AdventureWorks2012;"
  7.                       "Trusted_Connection=yes;")
  8. cursor = cnxn.cursor()
  9. sql = cursor.execute('SELECT * FROM HumanResources.Employee')
  11. df = pandas.read_sql(sql, cnxn)
  13. cursor.close()
  14. cnxn.close()
Aug 18 '17 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 616
There is no way to tell without a complete error message. The first question is always, does your user have permission to access the database and is there a password? The docs for pyodbc are at
Aug 18 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.