cs0815
cs0815

Reputation: 17418

connect to sql server from mac via sqlalchemy

I am switching from windows to mac. the below code works fine in windows. what would I have to adapt please? I get:

pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server Native Client 11.0' : file not found (0) (SQLDriverConnect)")

import urllib
import sqlalchemy as sa

def get_engine():
    connection_string = urllib.parse.quote_plus(
            "DRIVER={SQL Server Native Client 11.0};" 
            "SERVER=bla
            "DATABASE=bla
            "Trusted_Connection=yes"
        )
    return sa.create_engine("mssql+pyodbc:///?odbc_connect={}".format(connection_string))

Upvotes: 0

Views: 1485

Answers (1)

Art_Arnaud
Art_Arnaud

Reputation: 41

The code seems okay ! Did you try this answer from a similar question ?

https://stackoverflow.com/a/44546783/12497001

It seems that SQLAlchemy relies on a driver that it cannot find on your Mac.

Upvotes: 1

Related Questions