how to catch specific pyodbc error message

前端 未结 5 1083
北恋
北恋 2020-12-18 21:39

I trid the following code,

import pyodbc
try:
    pyodbc.connect(\'DRIVER={%s};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s\' % (driver, server, database, uid, passwo         


        
5条回答
  •  自闭症患者
    2020-12-18 22:08

    In pyodbc 3.0.7, it works fine to catch pyodbc.ProgrammingError (and presumably the other error types, although I haven't tried). The contents of the error are still sort of cryptic, though, so it may be hard to do finer-grained handling of errors.

提交回复
热议问题