-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent error tuples #1206
Comments
That is a problem. Also, I'd rather be able to get at the SQLSTATE directly via I wanted to end the 4.x line, but I would consider swapped constructor parameters a serious enough error to put out another release. I'll try to complete it this weekend. |
I'm having what I think to be related issue if only slightly. I'm handling errors returned from PYODBC dynamically as a way to map to HTTP Status in an API. In SQLSERVER I have a ID check as follows begin
; throw 51000, 'The Role does not exist.', 1;
end; Docs on throw: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/throw-transact-sql?view=sql-server-ver16 and from this pyodbc returns I'd greatly appreciate some way to get the error-code (51000) out from the ProgrammingError object returned from pyodbc, seperate from the SQLSTATE itself. Currently I have a hack in place that relies on regex and that is less than ideal. What are your thoughts @mkleehammer? Here is a link to the code that is related to this behavior I'm reporting Line 60 in 67162f0
|
I'm using pyodbc to perform tasks to insert data in sql server database. I wanted to catch certain errors and it looks like the error tuples generated do not follow a consistent structure. This makes it harder to handle errors dynamically in code.
For example:
So
IntegrityError
has structure:(code, message)
andProgrammingError
has structure(message, code)
.I wanted to do something in python like:
But this will not work as intended because of pyodbc's inconsistent error tuple structure. For the above example, the
ProgrammingError
code will be overlooked.The text was updated successfully, but these errors were encountered: