Python not getting data from SQL Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acg9999
    New Member
    • Aug 2017
    • 1

    Python not getting data from SQL Server

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

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


    Code:
    import pandas
    import pyodbc
    
    cnxn = pyodbc.connect("Driver={ODBC Driver 13 for SQL Server};"
                          "Server=localhost;"
                          "Database=AdventureWorks2012;"
                          "Trusted_Connection=yes;")
    cursor = cnxn.cursor()
    sql = cursor.execute('SELECT * FROM HumanResources.Employee')
    
    df = pandas.read_sql(sql, cnxn)
    
    cursor.close()
    cnxn.close()
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    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 https://github.com/mkleehammer/pyodbc/wiki

    Comment

    Working...