3-4 times a headache problem, export the data from DB to EXCEL, then import from EXCEL to DB, the data format error, cause an error.

Reflection:

1 way to solve the problem detour:

Before this problem occurs, the program is running correctly

Before problems arise, I accidentally deleted all the case testcase DB tables, and then import the data to excel in the message DB

Then all the election room card (check change deleted) The case ran illogical (associated case)

Charles reasons: to increase the election room card can be performed, but there is no correlation of the data source in question, resulting in the program does not find the correct cardid field, so check back dependent cardid of change deleted interface is not able to run through the

 

So the idea should be the right solution to the problem: 1 program has not changed, the updated data, suddenly ran nowhere, you should first check whether there is abnormal data source (simplified procedure, leaving only the code associated with the source data), instead of suspect a program bug, and enter debug mode terrible random

 

For improvement:

The cause of the matter is that tester to update case, delete her previous case, and then re-import the new case (because there are repeated), but accidentally deleted all the case, and reflect on their own can not directly manipulate data

Tester should be given permission to open, first of all by their first case, then put into a database in the test case library Test

Also you should have a page on the case batch CRUD , and should not be directly used to operate the database sql statement, misuse too risky

The problem I spent nearly five hours to solve. 3 hours to troubleshoot problems positioning, two hours to repair data. If you have a batch of case CRUD pages, I can liberate myself, let tester operating their own case, I only logical, rather than go to the maintenance case

 

Encountered a pit, not want to understand how it is

Pit: Why from DB (correct $ {cardid} = [data] [cardid] ') exported to EXCEL, and then introduced into EXCLE data DB (error [ "[' $ {cardid} = [data] [cardid] ' ] "]

), The format of the data it wrong

 

 

 How repeatedly the emergence of this issue it (the original is the problem of data sources, data source back and forth back problem ah)

 

After re-upload excel, data source error has occurred

[ "[ 'cardid $ {} = [date] [cardid]']" ] #错误
[ 'cardid $ {} = [date] [cardid]'] #正确

 

Troubleshooting Tips: Code has not changed, just update the data, the program wrong, it is clear that the program should not be examined, but should start from the data source checking ah

 

Debugging code 

Simplified procedure, leaving only a minimum of code that reproduces the bug 

Print the value of each one of the variables

Large split into small expressions of expression

 1 import re
 2 
 3 resp = {
 4     "status": "200",
 5     "msg": "OK",
 6     "isPC": 1,
 7     "data": { 8 "falg": 1, 9 "cardid": 150288, 10 "count": 0, 11 "msg": "保存选房卡条件数据成功!" 12  } 13 } 14 15 correlationDict={} 16 ["['${cardid}=[data][cardid]']"] #数据源错了 17 ['${cardid}=[data][cardid]']#正确的数据应该 是没有 外面一层[]的 18 correlation=['${cardid}=[data][cardid]'] 19 n = len(correlation)# n = 1 20 for j in range(len(correlation)): 21 param = correlation[j].split("=") 22 if len(param) == 2: 23 if param[1] == "" or not re.search(r'^\[', param[1]) or not re.search(r'\]', param[1]): 24 continue 25 value = resp 26 27 for key in param[1][1:-1].split("]["): 28 try: 29 temp = value[int(key)] 30 except: 31 try: 32 temp = value[key] 33 except: 34 break 35 value = temp 36 correlationDict[param[0]] = value 37 print("value%s"%value) 38 print(correlationDict)

 

坑:为什么从DB(正确 ${cardid}=[data][cardid]')导出到EXCEL,再把EXCLE的数据导入到DB(错误 ["['${cardid}=[data][cardid]']"]

),数据的格式 就错了呢

这中间发生了什么呢?



Guess you like

Origin www.cnblogs.com/kaerxifa/p/11119440.html