Skip to content

Commit d950586

Browse files
author
Melvyn Sopacua
committed
fix(1.11): Wrap pyodbc connection errors
When connections fail and we give up, return Django's OperationalError so basic scripts out there succeed.
1 parent 0cca47c commit d950586

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql_server/pyodbc/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from django.conf import settings
2424
from django.db.backends.base.base import BaseDatabaseWrapper
25-
from django.db.utils import ProgrammingError
25+
from django.db.utils import ProgrammingError, OperationalError
2626
from django.utils.encoding import smart_str
2727
from django.utils.functional import cached_property
2828
from django.utils.six import binary_type, text_type
@@ -315,7 +315,7 @@ def get_new_connection(self, conn_params):
315315
need_to_retry = False
316316
break
317317
if not need_to_retry:
318-
raise
318+
raise OperationalError(*e.args)
319319

320320
conn.timeout = query_timeout
321321
return conn

0 commit comments

Comments
 (0)