# Path: impala/util.py
# def _escape(s):
#     e = s
#     e = e.replace('\\', '\\\\')
#     e = e.replace('\n', '\\n')
#     e = e.replace('\r', '\\r')
#     e = e.replace("'", "\\'")
#     e = e.replace('"', '\\"')
#     log.debug('%s => %s', s, e)
#     return e
# 
# Path: impala/error.py
# class Error(Exception):
#     pass
# 
# class Warning(Exception):
#     pass
# 
# class InterfaceError(Error):
#     pass
# 
# class DatabaseError(Error):
#     pass
# 
# class InternalError(DatabaseError):
#     pass
# 
# class OperationalError(DatabaseError):
#     pass
# 
# class ProgrammingError(DatabaseError):
#     pass
# 
# class IntegrityError(DatabaseError):
#     pass
# 
# class DataError(DatabaseError):
#     pass
# 
# class NotSupportedError(DatabaseError):
#     pass


import datetime
import re
import six
from six import reraise
from impala.util import _escape
from impala.error import (  # pylint: disable=unused-import
    Error, Warning, InterfaceError, DatabaseError, InternalError,
    OperationalError, ProgrammingError, IntegrityError, DataError,
    NotSupportedError)
        from thrift_sasl import TSaslClientTransport
            reraise(exc_type, exc_val, exc_tb)


def _replace_numeric_markers(operation, string_parameters, paramstyle):
    """
    Replaces qname, format, and numeric markers in the given operation, from
    the string_parameters list.

    Raises ProgrammingError on wrong number of parameters or bindings
    when using qmark. There is no error checking on numeric parameters.
    """
    def replace_markers(marker, op, parameters):
        param_count = len(parameters)
        marker_index = 0
        start_offset = 0
        while True:
            found_offset = op.find(marker, start_offset)
            if not found_offset > -1:
                break
            if marker_index < param_count:
                op = op[:found_offset]+op[found_offset:].replace(marker, parameters[marker_index], 1)
                start_offset = found_offset + len(parameters[marker_index])
                marker_index += 1
            else:
                raise ProgrammingError("Incorrect number of bindings "
                                       "supplied. The current statement uses "
                                       "%d or more, and there are %d "
                                       "supplied." % (marker_index + 1,
                                                      param_count))
        if marker_index != 0 and marker_index != param_count:

# Path: impala/util.py
# def _escape(s):
#     e = s
#     e = e.replace('\\', '\\\\')
#     e = e.replace('\n', '\\n')
#     e = e.replace('\r', '\\r')
#     e = e.replace("'", "\\'")
#     e = e.replace('"', '\\"')
#     log.debug('%s => %s', s, e)
#     return e
# 
# Path: impala/error.py
# class Error(Exception):
#     pass
# 
# class Warning(Exception):
#     pass
# 
# class InterfaceError(Error):
#     pass
# 
# class DatabaseError(Error):
#     pass
# 
# class InternalError(DatabaseError):
#     pass
# 
# class OperationalError(DatabaseError):
#     pass
# 
# class ProgrammingError(DatabaseError):
#     pass
# 
# class IntegrityError(DatabaseError):
#     pass
# 
# class DataError(DatabaseError):
#     pass
# 
# class NotSupportedError(DatabaseError):
#     pass


# Path: impala/interface.py
import datetime
import re
import six
from six import reraise
from impala.util import _escape
from impala.error import (  # pylint: disable=unused-import
    Error, Warning, InterfaceError, DatabaseError, InternalError,
    OperationalError, ProgrammingError, IntegrityError, DataError,
    NotSupportedError)
        from thrift_sasl import TSaslClientTransport

            reraise(exc_type, exc_val, exc_tb)


def _replace_numeric_markers(operation, string_parameters, paramstyle):
    """
    Replaces qname, format, and numeric markers in the given operation, from
    the string_parameters list.

    Raises ProgrammingError on wrong number of parameters or bindings
    when using qmark. There is no error checking on numeric parameters.
    """
    def replace_markers(marker, op, parameters):
        param_count = len(parameters)
        marker_index = 0
        start_offset = 0
        while True:
            found_offset = op.find(marker, start_offset)
            if not found_offset > -1:
                break
            if marker_index < param_count:
                op = op[:found_offset]+op[found_offset:].replace(marker, parameters[marker_index], 1)
                start_offset = found_offset + len(parameters[marker_index])
                marker_index += 1
            else:
                raise ProgrammingError("Incorrect number of bindings "
                                       "supplied. The current statement uses "
                                       "%d or more, and there are %d "
                                       "supplied." % (marker_index + 1,
                                                      param_count))
        if marker_index != 0 and marker_index != param_count:

            raise ProgrammingError("Incorrect number of bindings "