Hi @Ирина Грачева,
Try the following minimal script using a downgraded pyodbc:
import pyodbc
conn_str = ("DRIVER={ODBC Driver 17 for SQL Server};"
"SERVER=localhost,1433;"
"UID=admin;PWD=password;"
"DATABASE=master;")
print("Connecting …")
conn = pyodbc.connect(conn_str)
cursor = conn.cursor()
cursor.execute("SELECT GETDATE()")
row = cursor.fetchone()
print("SQL Server date:", row[0])
conn.close()
print("Done")
- Run it under a debugger (lldb / gdb) so you catch the segfault stack.
- If it works, then try via SQLAlchemy.
- If it fails, try the same with pyodbc==4.0.32
There are known issues with newer pyodbc builds on macOS causing segmentation faults with the ODBC 17 driver. Using version 4.0.32 usually fixes it.
Regards, Akhil.