Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_tsql_to_python_exception_translation(self):
"""An error raised by a SP is translated to a PEP-249-dictated, pymssql layer exception."""
# See https://github.com/pymssql/pymssql/issues/61
cursor = self.pymssql.cursor()
# Must raise an exception
self.assertRaises(Exception, cursor.callproc, 'SPThatRaisesAnError')
# Must be a PEP-249 exception, not a _mssql-layer one
try:
cursor.callproc('SPThatRaisesAnError')
except Exception as e:
self.assertTrue(isinstance(e, pymssql.Error))
# Must be a DatabaseError exception
try:
cursor.callproc('SPThatRaisesAnError')
except Exception as e:
self.assertTrue(isinstance(e, pymssql.DatabaseError))
class Warning(StandardError):
pass
class Error(StandardError):
pass
class InterfaceError(Error):
pass
class DatabaseError(Error):
pass
class DataError(DatabaseError):
pass
class OperationalError(DatabaseError):
pass
class IntegrityError(DatabaseError):
pass
class InternalError(DatabaseError):
pass
class ProgrammingError(DatabaseError):
pass
class NotSupportedError(DatabaseError):
pass
### cursor object
import datetime
from django.utils import timezone
import pymssql as Database
from sqlserver_ado.base import (
DatabaseFeatures as _DatabaseFeatures,
DatabaseOperations as _DatabaseOperations,
DatabaseWrapper as _DatabaseWrapper)
DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError
VERSION_SQL2000 = 8
VERSION_SQL2005 = 9
VERSION_SQL2008 = 10
def _fix_query(query):
# For Django's inspectdb tests -- a model has a non-ASCII column name.
if not isinstance(query, str):
query = query.encode('utf-8')
# For Django's backends and expressions_regress tests.
query = query.replace('%%', '%')
return query
class DataError(DatabaseError):
pass
class OperationalError(DatabaseError):
pass
class IntegrityError(DatabaseError):
pass
class InternalError(DatabaseError):
pass
class ProgrammingError(DatabaseError):
pass
class NotSupportedError(DatabaseError):
pass
### cursor object
class pymssqlCursor(object):
"""
This class represent a database cursor, which is used to issue queries
and fetch results from a database connection.
"""
def __init__(self, src, as_dict):
"""
Initialize a Cursor object. 'src' is a pymssqlCnx object instance.
"""
self.__source = src
class DatabaseError(Error):
pass
class DataError(DatabaseError):
pass
class OperationalError(DatabaseError):
pass
class IntegrityError(DatabaseError):
pass
class InternalError(DatabaseError):
pass
class ProgrammingError(DatabaseError):
pass
class NotSupportedError(DatabaseError):
pass
### cursor object
class pymssqlCursor(object):
"""
This class represent a database cursor, which is used to issue queries
and fetch results from a database connection.
"""
def __init__(self, src, as_dict):
"""
class InterfaceError(Error):
pass
class DatabaseError(Error):
pass
class DataError(DatabaseError):
pass
class OperationalError(DatabaseError):
pass
class IntegrityError(DatabaseError):
pass
class InternalError(DatabaseError):
pass
class ProgrammingError(DatabaseError):
pass
class NotSupportedError(DatabaseError):
pass
### cursor object
class pymssqlCursor(object):
"""
This class represent a database cursor, which is used to issue queries
and fetch results from a database connection.
"""
### exception hierarchy
class Warning(StandardError):
pass
class Error(StandardError):
pass
class InterfaceError(Error):
pass
class DatabaseError(Error):
pass
class DataError(DatabaseError):
pass
class OperationalError(DatabaseError):
pass
class IntegrityError(DatabaseError):
pass
class InternalError(DatabaseError):
pass
class ProgrammingError(DatabaseError):
pass
class NotSupportedError(DatabaseError):
pass
class Error(StandardError):
pass
class InterfaceError(Error):
pass
class DatabaseError(Error):
pass
class DataError(DatabaseError):
pass
class OperationalError(DatabaseError):
pass
class IntegrityError(DatabaseError):
pass
class InternalError(DatabaseError):
pass
class ProgrammingError(DatabaseError):
pass
class NotSupportedError(DatabaseError):
pass
### cursor object
class pymssqlCursor(object):
"""