Comments (7)
Original comment by [email protected]
on 8 Mar 2012 at 3:16
- Changed state: Accepted
from pymssql.
I took a stab at this that seems to work but needs more testing and review from
some more eyes. This change adds more info to MSSQLDatabaseException:
http://code.google.com/r/msabramo-pymssql-issue41/source/detail?r=3d3d5934c2548d
24f83bdd9d01355ea585f11611
Sample usage:
vagrant@lucid64:~/dev/hg-repos/msabramo-pymssql-issue41$ .tox/py26/bin/python
issue_41_mssql.py
Traceback (most recent call last):
File "issue_41_mssql.py", line 11, in
charset='UTF-8')
File "_mssql.pyx", line 1658, in _mssql.connect (_mssql.c:17029)
return MSSQLConnection(_args, *_kwargs)
File "_mssql.pyx", line 519, in _mssql.MSSQLConnection.init (_mssql.c:5007)
maybe_raise_MSSQLDatabaseException(None)
File "_mssql.pyx", line 1398, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:13506)
raise ex
_mssql.MSSQLDatabaseException: DB: 'Unable to connect: Adaptive Server is
unavailable or does not exist', OS: 'Connection refused', tdscode: 20009,
tdsmsg: 'Net-Lib error during Connection refused'
I didn't do anything with `pymssql.OperationalError` yet, which is what gets
thrown if you use `pymssql.connect` rather than _mssql.connect.
Original comment by [email protected]
on 15 Jan 2013 at 3:51
from pymssql.
If I do:
vagrant@lucid64:~/dev/hg-repos/msabramo-pymssql-issue41$ hg diff
diff -r 3d3d5934c254 pymssql.pyx
--- a/pymssql.pyx Tue Jan 15 07:47:20 2013 -0800
+++ b/pymssql.pyx Tue Jan 15 08:10:08 2013 -0800
@@ -553,7 +553,7 @@
appname, port)
except _mssql.MSSQLDatabaseException, e:
-
raise OperationalError(e[0])
-
raise OperationalError(e)
except _mssql.MSSQLDriverException, e:
raise InterfaceError(e[0])
then I get a nicer exception when `pymssql.connect` fails:
vagrant@lucid64:~/dev/hg-repos/msabramo-pymssql-issue41$ .tox/py26/bin/python
issue_41.py
Traceback (most recent call last):
File "issue_41.py", line 12, in
charset='UTF-8')
File "pymssql.pyx", line 556, in pymssql.connect (pymssql.c:7990)
raise OperationalError(e)
pymssql.OperationalError: DB: 'Unable to connect: Adaptive Server is
unavailable or does not exist', OS: 'Connection refused', tdscode: 20009,
tdsmsg: 'Net-Lib error during Connection refused'
but I don't understand what `e[0]` was doing, so not sure if it's OK to change
it. If it is OK, then there are a bunch of places in `pymssql.pyx` that catch
MSSQLDatabaseException and raise an OperationalError and perhaps these should
be changed as well, but these are lot of hard-to-reproduce edge cases, so I'm
not sure how to proceed.
Original comment by [email protected]
on 15 Jan 2013 at 4:17
from pymssql.
Original comment by [email protected]
on 7 Aug 2013 at 1:56
- Added labels: Type-Enhancement, patchincluded, needstesting
- Removed labels: Type-Defect
from pymssql.
> Traceback (most recent call last):
File "issue_41.py", line 12, in <module>
charset='UTF-8')
File "pymssql.pyx", line 556, in pymssql.connect (pymssql.c:7990)
raise OperationalError(e)
pymssql.OperationalError: DB: 'Unable to connect: Adaptive Server is
unavailable or does not exist', OS: 'Connection refused', tdscode: 20009,
tdsmsg: 'Net-Lib error during Connection refused'
but I don't understand what
e[0]
was doing, so not sure if it's OK to
change it.
From PEP 3110 and PEP 352 an exception instance could (before Python 3) be
accessed
by index. The values obtained were the ones passes when instantiaging/raising
it (if
any), in the same order.
So when pymssql.pyx catches MSSQLDatabaseException as e
and the treats it
raising a pymssql-level exception with value e[0] it's actually passing to the
user
the two-element tuple with which maybe_raise_MSSQLDatabaseException() is
instantiating it:
MSSQLDatabaseException((get_last_msg_no(conn), get_last_msg_str(conn)))
The tuple is the one we are uded to see when dealing with pymssql/[Feee]TDS:
(20009, 'Net-Lib error during Connection refused')
Something similar (but simpler) happens when it catches MSSQLDriverException as
e,
raising a new exception with value e[0] simply makes the string reported by
_mssql.pyx bubble up to the user.
Original comment by `[email protected]` on 16 Aug 2013 at 10:37
from pymssql.
Original comment by [email protected]
on 23 Sep 2013 at 10:06
- Removed labels: patchincluded
from pymssql.
Original comment by [email protected]
on 23 Sep 2013 at 10:15
- Removed labels: needstesting
from pymssql.
Related Issues (20)
- Failure to pass Unicode characters to callproc; failing test: tests.test_sprocs.TestCallProcFancy.testCallProcWithUnicodeStringWithRussianCharacters HOT 7
- When pymssql.connect() - DB-Lib error message 20002, severity 9;Adaptive Server connection failed HOT 1
- Fix test_config.py typos. HOT 1
- Small fix about TDS protocol version in a comment HOT 1
- Fix a small bug in SP tests HOT 3
- Fix SP name handling in threaded test so we can actually run it. HOT 2
- Feature for discussion (with patch): pymssql_shell HOT 2
- A few tests fail if running on a system that has SQL Server available on port 1433 HOT 1
- add function for getting FreeTDS version HOT 1
- datetime conversion to sql is not converting sub-seconds correctly HOT 5
- memory leaks (patches included) HOT 24
- pymssql-2.0.0b1-dev-20130403.tar.gz doesn't compile due to /usr/bin/ld: cannot find -lct HOT 8
- Installer issue HOT 1
- error: unrecognized command line option "-Wno-parentheses-equality" HOT 8
- pymssql.so: undefined symbol: __fread_chk HOT 5
- Support "with" statement (PEP 343) HOT 5
- Can't compile on OS X 10.8.4 HOT 10
- Review pymssql result processing code
- Make Cython not necessary when pymssql.c and _mssql.c are already present HOT 1
- IOError: [Errno 2] No such file or directory: 'ChangeLog_highlights.rst' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymssql.