Example #1
0
 except Exception,ex:
     logger.warn(msg="执行SQL[{id}]错误: {ex}".format(id=id,ex=str(ex)))
 if  order.sql_audit_order.order_type == 'online':          
     try:
         config = SQL_Audit_Control.objects.get(id=1)
         incept = Inception(
                            host=order.sql_audit_order.order_db.db_host,
                            name=order.sql_audit_order.order_db.db_name,
                            user=order.sql_audit_order.order_db.db_user,
                            passwd=order.sql_audit_order.order_db.db_passwd,
                            port=order.sql_audit_order.order_db.db_port
                            )
         if config.t_backup_sql == 0 and order.sql_audit_order.order_db.db_env == 'test':action = '--disable-remote-backup;'
         elif config.p_backup_sql == 0 and order.sql_audit_order.order_db.db_env == 'prod':action = '--disable-remote-backup;'
         else:action = None
         result = incept.execSql(order.sql_audit_order.order_sql,action)
         if result.get('status') == 'success':
             count = 0
             sList = []
             for ds in result.get('data'):
                 try:                            
                     SQL_Order_Execute_Result.objects.create(
                                                             order = order.sql_audit_order,
                                                             errlevel = ds.get('errlevel'),
                                                             stage = ds.get('stage'),
                                                             stagestatus = ds.get('stagestatus'),
                                                             errormessage = ds.get('errmsg'),
                                                             sqltext =  ds.get('sql'),
                                                             affectrow = ds.get('affected_rows'),
                                                             sequence = ds.get('sequence'),
                                                             backup_db = ds.get('backup_dbname'),
Example #2
0
    print ex
    pass
try:
    config = SQL_Audit_Control.objects.get(id=1)
    incept = Inception(host=order.order_db.db_host,
                       name=order.order_db.db_name,
                       user=order.order_db.db_user,
                       passwd=order.order_db.db_passwd,
                       port=order.order_db.db_port)
    if config.t_backup_sql == 0 and order.order_db.db_env == 'test':
        action = '--disable-remote-backup;'
    elif config.p_backup_sql == 0 and order.order_db.db_env == 'prod':
        action = '--disable-remote-backup;'
    else:
        action = None
    result = incept.execSql(order.order_sql, action)
    if result.get('status') == 'success':
        count = 0
        sList = []
        for ds in result.get('data'):
            try:
                SQL_Order_Execute_Result.objects.create(
                    order=order,
                    errlevel=ds.get('errlevel'),
                    stage=ds.get('stage'),
                    stagestatus=ds.get('stagestatus'),
                    errormessage=ds.get('errmsg'),
                    sqltext=ds.get('sql'),
                    affectrow=ds.get('affected_rows'),
                    sequence=ds.get('sequence'),
                    backup_db=ds.get('backup_dbname'),
Example #3
0
     count = SQL_Order_Execute_Result.objects.filter(order=order).count() 
     if count > 0:return JsonResponse({'msg':"该SQL已经被执行过,请勿重复执行","code":500,'data':[]})
 except Exception,ex:
     print ex
     pass            
 try:
     config = SQL_Audit_Control.objects.get(id=1)
     incept = Inception(
                        host=order.order_db.db_host,name=order.order_db.db_name,
                        user=order.order_db.db_user,passwd=order.order_db.db_passwd,
                        port=order.order_db.db_port
                        )
     if config.t_backup_sql == 0 and order.order_db.db_env == 'test':action = '--disable-remote-backup;'
     elif config.p_backup_sql == 0 and order.order_db.db_env == 'prod':action = '--disable-remote-backup;'
     else:action = None
     result = incept.execSql(order.order_sql,action)
     if result.get('status') == 'success':
         count = 0
         sList = []
         for ds in result.get('data'):
             try:                            
                 SQL_Order_Execute_Result.objects.create(
                                                         order = order,
                                                         errlevel = ds.get('errlevel'),
                                                         stage = ds.get('stage'),
                                                         stagestatus = ds.get('stagestatus'),
                                                         errormessage = ds.get('errmsg'),
                                                         sqltext =  ds.get('sql'),
                                                         affectrow = ds.get('affected_rows'),
                                                         sequence = ds.get('sequence'),
                                                         backup_db = ds.get('backup_dbname'),
Example #4
0
 if order.sql_audit_order.order_type == 'online':
     try:
         config = SQL_Audit_Control.objects.get(id=1)
         incept = Inception(
             host=order.sql_audit_order.order_db.db_host,
             name=order.sql_audit_order.order_db.db_name,
             user=order.sql_audit_order.order_db.db_user,
             passwd=order.sql_audit_order.order_db.db_passwd,
             port=order.sql_audit_order.order_db.db_port)
         if config.t_backup_sql == 0 and order.sql_audit_order.order_db.db_env == 'test':
             action = '--disable-remote-backup;'
         elif config.p_backup_sql == 0 and order.sql_audit_order.order_db.db_env == 'prod':
             action = '--disable-remote-backup;'
         else:
             action = None
         result = incept.execSql(order.sql_audit_order.order_sql,
                                 action)
         if result.get('status') == 'success':
             count = 0
             sList = []
             for ds in result.get('data'):
                 try:
                     SQL_Order_Execute_Result.objects.create(
                         order=order.sql_audit_order,
                         errlevel=ds.get('errlevel'),
                         stage=ds.get('stage'),
                         stagestatus=ds.get('stagestatus'),
                         errormessage=ds.get('errmsg'),
                         sqltext=ds.get('sql'),
                         affectrow=ds.get('affected_rows'),
                         sequence=ds.get('sequence'),
                         backup_db=ds.get('backup_dbname'),