#NEWLINE# def _ToDbApiException( sql_exception ) : #NEWLINE# #INDENT# 'Returns a DB-API exception type appropriate for the given sql_exception.\n\n  Args:\n    sql_exception: The client_pb2.SqlException.\n\n  Returns:\n    The appropriate DatabaseError subclass for the error code in the given\n    sql_exception.\n  ' #NEWLINE# exception = _ERROR_CODE_TO_EXCEPTION . get ( sql_exception . code ) #NEWLINE# if ( not exception ) : #NEWLINE# #INDENT# if ( sql_exception . code < 1000 ) : #NEWLINE# #INDENT# exception = InternalError #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exception = OperationalError #NEWLINE# #UNINDENT# #UNINDENT# return exception ( exception . code , sql_exception . message )