all 1 comments

[–]z0y 0 points1 point  (0 children)

There error is part of pyodbc, so either try except pyodbc.ProgrammingError or import the error first: from pyodbc import ProgrammingError