Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server pyodbc Driver issue: libc++abi.dylib: terminating with uncaught exception of type std::runtime_error

I am trying to connect to my SQL Server Database using python with pyodbc on my Mac. The full error I get when I run is:

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: collate_byname::collate_byname failed to construct for C/en_CA.

The Python code to connect using the driver is:

import pyodbc

cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server}"
                  "Server=simvo-dbs.database.windows.net,1433;"
                  "Database=degree-planner-db;"
                  "UID=simvo_admin@simvo-dbs;"
                  "PWD=McGill_514;"
                  "loginTimeout=30;")

Other Relevant Files:

odbcinst.ini:

[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/usr/local/lib/libmsodbcsql.17.dylib
UsageCount=1

odbc.ini:

[MSSQL]
TDS_Version = 7.3
Driver = ODBC Driver 17 for SQL Server
Server = simvo-dbs.database.windows.net
Port = 1433

Any idea on what the issue is will be greatly appreciated. I am using a MAC.

like image 777
John Nnamchi Avatar asked Feb 18 '26 15:02

John Nnamchi


1 Answers

I have the same issue and there is no solution, as far as I can tell. But you can workaround it running the script like this:

env LANG=C python3 myscript.py

I hope it helps.

like image 200
Alexandre Avatar answered Feb 20 '26 12:02

Alexandre