Beispiel #1
0
    def getJobCount(self):
        try:
            super(JobDAO, self).getConnection()
            sql_c = "select count from t_c_job"
            result_c = super(JobDAO, self).fetchall(sql_c)

            sql_java = "select count from t_java_job"
            result_java = super(JobDAO, self).fetchall(sql_java)

            sql_py = "select count from t_py_job"
            result_py = super(JobDAO, self).fetchall(sql_py)

            sql_ai = "select count from t_ai_job"
            result_ai = super(JobDAO, self).fetchall(sql_ai)

            sql_web = "select count from t_qd_job"
            result_web = super(JobDAO, self).fetchall(sql_web)

            super(JobDAO, self).commit()
            return result_c, result_java, result_py, result_ai, result_web
            pass
        except Exception as e:
            logger.error("执行SQL:" + sql_c + "出现异常:" + str(e))
            pass
        finally:
            pass
Beispiel #2
0
 def executemany(self, sql, param):
     try:
         if self.__cursor and self.__conn:
             self.__cursor.executemany(sql, param)
     except:
         logger.error("执行语句:" + sql + str(param))
         self.__cursor.close()
         self.__conn.close()
Beispiel #3
0
 def getConnection(self):
     try:
         self.__conn = pymysql.connect(self.__host, self.__name, self.__pwd,self.__dbname,charset=self.__charset)
     except (pymysql.MySQLError, pymysql.DatabaseError, Exception):
         logger.error("数据库连接异常:" + self.__host)
         pass
     self.__cursor = self.__conn.cursor()
     pass
Beispiel #4
0
 def execute(self, sql, param=None):
     try:
         if self.__conn and self.__cursor:
             if param:
                 self.__cursor.execute(sql, param)
             else:
                 self.__cursor.execute(sql)
     except:
         logger.error("执行语句:" + sql, str(param))
         self.__cursor.close()
         self.__conn.close()
Beispiel #5
0
 def getAllUsers(self):
     try:
         super().getConnection()
         sqlSelect = "select * from t_user "
         result = super().fetchall(sqlSelect)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
 def getmysqlport(self):
     try:
         super().getConnection()
         sqlSelect = "select * from t_port where port = '3306'"
         result = super().fetchall(sqlSelect)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
 def insertvultotal(self, ip, danger):
     try:
         super().getConnection()
         sqlinsersqlvul = "update t_total set %s=%s + 1 where ip=%s"%(danger,danger,ip)
         result = super().execute(sqlinsersqlvul)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e))
     finally:
         super().close()
Beispiel #8
0
    def getConnection(self):
        try:
            self.__conn = pymysql.connect(self.__host,
                                          self.__username,
                                          self.__password,
                                          self.__schema,
                                          charset=self.__charset)

        except (pymysql.DatabaseError, pymysql.MySQLError, Exception):
            logger.error("数据库连接失败。。。  " + self.__host)
        self.__cursor = self.__conn.cursor()
 def getpriescvul(self, prilist):
     try:
         super().getConnection()
         sqlSelect = "select * from t_vul where ip = %s and typeid = '3'"
         params = (prilist)
         result = super().fetchall(sqlSelect, params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e))
     finally:
         super().close()
 def getsshpass(self,idpass):
     try:
         super().getConnection()
         sqlSelect = "select * from t_weakpass where typeid = %s"
         params = (idpass)
         result = super().fetchall(sqlSelect,params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
 def getport(self,portlist):
     try:
         super().getConnection()
         sqlSelect = "select * from t_port where ip = %s"
         params = (portlist)
         result = super().fetchall(sqlSelect,params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
Beispiel #12
0
 def getJobYw(self):
     try:
         super().getConnection()
         sql = "select maxsalary,minsalary,avgsalary,jobcount from t_yw"
         result = super().fetchall(sql)
         super().commit()
         return result
         pass
     except Exception as e:
         logger.error()
     finally:
         super().close()
Beispiel #13
0
 def getUserinfo(self,name):
     try:
         super().getConnection()
         sqlSelect = "select userpwd from t_user where username = %s"
         params = (name)
         result = super().fetchall(sqlSelect,params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e))
     finally:
         super().close()
Beispiel #14
0
 def getJobWeb(self):
     try:
         super(JobDAO, self).getConnection()
         sql = "select max,min,avg from t_qd_job"
         result = super(JobDAO, self).fetchall(sql)
         super(JobDAO, self).commit()
         return result
         pass
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常:" + str(e))
     finally:
         super(JobDAO, self).close()
Beispiel #15
0
 def getJobCounts(self):
     try:
         super().getConnection()
         sql = "select count(*) from t_job_info"
         result = super().fetchall(sql)
         super().commit()
         # print(result)
         return result
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常,params:" + " " + str(e))
     finally:
         super().close()
Beispiel #16
0
 def executeQuery(self, sql, param, row='one'):
     try:
         if self.__cursor and self.__conn:
             self.__cursor.execute(sql, param)
             if row == 'one':
                 return self.__cursor.fetchone()
             else:
                 return self.__cursor.fetchall()
     except:
         logger.error("执行语句:" + sql)
         self.__cursor.close()
         self.__conn.close()
 def insertports(self,ip,port,protocol,status,service):
     # ip, port, protocol, status, service
     try:
         super().getConnection()
         sqlinsertport = "insert into t_port (ip,port,protocol,status,service) values (%s,%s,%s,%s,%s)"
         params = (ip,port,protocol,status,service)
         result = super().execute(sqlinsertport, params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
Beispiel #18
0
 def deleteUserById(self, userId):
     try:
         super().getConnection()
         sqlDelete= "delete from t_user where userId=%s"
         params = (userId,)
         result = super().execute(sqlDelete, params)
         super().commit()
         return result
     except Exception as e:
         super().rollback()
         logger.error("执行SQL:" + sqlDelete + " 出现异常,params:" + params + str(e))
     finally:
         super().close()
Beispiel #19
0
 def getUserByUserNameAndPwd(self, user):
     try:
         super().getConnection()
         sqlSelect = "select roleid,username, userpwd from t_user where username=%s and userpwd=%s"
         params = (user.userName, user.userPwd)
         result = super().fetchone(sqlSelect, params)
         print(result)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + params + " " + str(e) )
     finally:
         super().close()
Beispiel #20
0
 def getLimitJobCitys(self, city, currentPage, pageNO):
     try:
         super().getConnection()
         sql = "select * from t_job_info where jobCity = %s limit %s,%s"
         params = (city, (currentPage - 1) * pageNO, pageNO)
         result = super().fetchall(sql, params)
         super().commit()
         # print(result)
         return result
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常,params:" + " " + str(e))
     finally:
         super().close()
 def inserthosts(self,system,accuracy,Host):
     # system,accuracy
     try:
         super().getConnection()
         sqlinserthost = "insert into t_host (system,accuracy,ip) values (%s,%s,%s)"
         params = (system,accuracy,Host)
         result = super().execute(sqlinserthost, params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
Beispiel #22
0
 def getLimitJobPosition(self, position, currentPage, pageNO):
     try:
         super().getConnection()
         sql = "select * from t_job_info where jobPosition like '%{0}%' limit {1},{2}".format(
             position, (currentPage - 1) * pageNO, pageNO)
         result = super().fetchall(sql)
         super().commit()
         # print(result)
         return result
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常,params:" + " " + str(e))
     finally:
         super().close()
Beispiel #23
0
 def getJobNumCity(self, city):
     try:
         super().getConnection()
         sql = "select count(*) from t_job_info where jobCity = %s"
         params = (city, )
         result = super().fetchall(sql, params)
         super().commit()
         # print(result)
         return result
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常,params:" + " " + str(e))
     finally:
         super().close()
 def insertsshweak(self,idpass,host,weaktype,weakuser,weakpwd):
     # idpass,weaktype,weakuser,weakpwd
     try:
         super().getConnection()
         sqlinsertip = "insert into t_weakpass (idpass,ip,weaktype,weakuser,weakpass) values (%s,%s,%s,%s,%s)"
         params = (idpass,host,weaktype,weakuser,weakpwd)
         result = super().execute(sqlinsertip, params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
Beispiel #25
0
 def getJobNumPosition(self, position):
     try:
         super().getConnection()
         sql = "select count(*) from t_job_info where jobPosition like '%{0}%'".format(
             position)
         result = super().fetchall(sql)
         super().commit()
         # print(result)
         return result
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常,params:" + " " + str(e))
     finally:
         super().close()
Beispiel #26
0
 def setUserTelByName(self, user, telvalue):
     try:
         super().getConnection()
         sql = "update t_user set usertel = '{0}' where username = '******'".format(
             telvalue, user.username)
         result = super().execute(sql)
         super().commit()
         # print(result)
         return result
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常,params:" + " " + str(e))
     finally:
         super().close()
Beispiel #27
0
 def getLimitJobByMaxSalary(self, currentPage, pageNO):
     try:
         super().getConnection()
         sql = "select * from t_job_info order by jobMaxsalary desc limit %s,%s"
         params = (currentPage, pageNO)
         result = super().fetchall(sql, params)
         super().commit()
         # print(result)
         return result
     except Exception as e:
         logger.error("执行SQL:" + sql + " 出现异常,params:" + " " + str(e))
     finally:
         super().close()
 def getnmapinfo(self, vullist):
     try:
         super().getConnection()
         vulSelect = "select domain_name from t_ip where ip = %s"
         params = (vullist)
         result = super().fetchall(vulSelect, params)
         print(result)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e))
     finally:
         super().close()
 def insertpaths(self,ip,domainname,path,state):
     # system,accuracy
     try:
         super().getConnection()
         sqlinsertpath = "insert into t_path (ip,domainname,path,state) values (%s,%s,%s,%s)"
         params = (ip,domainname,path,state)
         result = super().execute(sqlinsertpath, params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()
 def insertips(self,ip,domianname):
     # ip,domianname
     try:
         super().getConnection()
         sqlinsertip = "insert into t_ip (ip,domain_name) values (%s,%s)"
         params = (ip,domianname)
         result = super().execute(sqlinsertip, params)
         super().commit()
         return result
     except Exception as e:
         logger.error("执行SQL:" + sqlSelect + " 出现异常,params:" + str(e) )
     finally:
         super().close()