]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added disconnect checks for timeout, unable to read, and unable to write
authorJohn Anderson <sontek@gmail.com>
Mon, 18 Mar 2013 21:49:28 +0000 (14:49 -0700)
committerJohn Anderson <sontek@gmail.com>
Mon, 18 Mar 2013 21:49:28 +0000 (14:49 -0700)
lib/sqlalchemy/dialects/mssql/pymssql.py
test/dialect/test_mssql.py

index 6f6d3b01fdfe60ceb08157766838c0b12d481522..0754f7f764d87f0c9f6a12ca9e3d071cf832d6e5 100644 (file)
@@ -85,6 +85,9 @@ class MSDialect_pymssql(MSDialect):
 
     def is_disconnect(self, e, connection, cursor):
         for msg in (
+            "Error 20003",  # Connection Timeout
+            "Error 20004",  # Read from SQL server failed
+            "Error 20006",  # Write to SQL Server failed
             "Error 10054",
             "Not connected to any MS SQL server",
             "Connection is closed"
index 06f3d2805e008e6ba642480aa9b568306bac69e3..b38d763723897bc56c361d5c98c4ea412b61f525 100644 (file)
@@ -1320,6 +1320,12 @@ class ParseConnectTest(fixtures.TestBase, AssertsCompiledSQL):
                     'user': 'scott', 'database': 'test'}], connection
         )
 
+    def test_pymssql_disconnect(self):
+        dialect = pymssql.dialect()
+
+        for error in ['20003', '20003', '20006']:
+            eq_(dialect.is_disconnect('Error %s' % error, None, None), True)
+
     @testing.only_on(['mssql+pyodbc', 'mssql+pymssql'], "FreeTDS specific test")
     def test_bad_freetds_warning(self):
         engine = engines.testing_engine()