InterfaceError: (pyodbc.InterfaceError) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

asked 2022-06-29T19:52:40.257+00:00
Addie, Andrew 1 Reputation point

I was required to update Anaconda and now when I try to connect sqlalchemy to my database I get the error above. The command I previously used is below
engine = create_engine('mssql+pyodbc://' + server + '/' + database + '?driver=SQL Server?Trusted_Connection=yes', echo = True)
I am very much a NOOB with all these connection issues and appreciate the help. How do I fix this? What other information do you need to help?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
8,482 questions
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2022-06-30T02:43:13.307+00:00
    YufeiShao-msft 6,871 Reputation points

    Hi @Addie, Andrew

    First of all, it should be clear that this is a SQL Server forum, we are not familiar with sqlalchemy and cannot give help with it.

    Please check version of ODBC driver, not sure if the code you shown is complete, but you may need 'DRIVER={ODBC Driver 17 for SQL Server}' instead driver=SQL Server

    https://datadiaries.dev/connecting-to-microsoft-sql-server-using-sqlalchemy-and-pyodbc

    -------------

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.