コード例 #1
0
ファイル: database.py プロジェクト: amoyx/OpsManage
                            user=dbServer.db_user,passwd=dbServer.db_passwd,
                            port=dbServer.db_port
                            )
         result = incept.checkSql(request.POST.get('sql'))
         if result.get('status') == 'success':
             count = 0
             errStr = ''
             for ds in result.get('data'):
                 if ds.get('errlevel') > 0 and ds.get('errmsg'):
                     count = count + 1
                     errStr = errStr +ds.get('errmsg')
             if count > 0:return JsonResponse({'msg':"审核失败,请检查SQL语句","code":500,'data':errStr,'tag':2}) 
         else:
             return JsonResponse({'msg':"Inception审核失败","code":500,'data':result.get('errinfo'),'tag':2})             
         status,result = base.getSQLAdvisor(host=dbServer.db_host, user=dbServer.db_user,
                                            passwd=dbServer.db_passwd, dbname=dbServer.db_name, 
                                            sql=request.POST.get('sql'),port=dbServer.db_port)
         if status == 0:
             return JsonResponse({'msg':"获取SQL优化数据成功","code":200,'data':result,'tag':2}) 
         else:
             return JsonResponse({'msg':"获取SQL优化数据失败","code":500,'data':result,'tag':2}) 
     else:return JsonResponse({'msg':"获取SQL优化数据失败","code":500,'data':[],'tag':2})
     
 elif request.method == "POST" and request.POST.get('opsTag') == '3':#执行DQL
     if re.match(r"^(\s*)?select(\S+)?(.*)", request.POST.get('sql').lower()):            
         try:
             dbServer = DataBase_Server_Config.objects.get(id=int(request.POST.get('dbId')))
         except Exception, ex:
             dbServer = None 
         if dbServer:
             mysql = MySQLPool(host=dbServer.db_host,port=dbServer.db_port,user=dbServer.db_user,passwd=dbServer.db_passwd,dbName=dbServer.db_name)
コード例 #2
0
ファイル: database.py プロジェクト: yy1117/OpsManage
         return JsonResponse({
             'msg': "审核失败,请检查SQL语句",
             "code": 500,
             'data': errStr,
             'tag': 2
         })
 else:
     return JsonResponse({
         'msg': "Inception审核失败",
         "code": 500,
         'data': result.get('errinfo'),
         'tag': 2
     })
 status, result = base.getSQLAdvisor(host=dbServer.db_host,
                                     user=dbServer.db_user,
                                     passwd=dbServer.db_passwd,
                                     dbname=dbServer.db_name,
                                     sql=request.POST.get('sql'),
                                     port=dbServer.db_port)
 if status == 0:
     return JsonResponse({
         'msg': "获取SQL优化数据成功",
         "code": 200,
         'data': result,
         'tag': 2
     })
 else:
     return JsonResponse({
         'msg': "获取SQL优化数据失败",
         "code": 500,
         'data': result,
         'tag': 2