def insertpositionforce(self,key_word_id,position,day,month,year): '''Insert position yandex output (force)''' self.cursor.execute("SELECT * FROM positions WHERE key_word_id = '" + str(key_word_id) + "' AND position = '" + str(position) + "' AND day = '" + day + "' AND month = '" + month + "' AND year = '" + year + "'") if MysqlProvider._getrowcount(self)==0: self.cursor.execute("INSERT INTO positions SET key_word_id = '" + str(key_word_id) + "',position = '" + str(position) + "',day = '" + day + "',month = '" + month + "',year = '" + year + "'") else: result=self.cursor.fetchall() id=result[0]['id'] self.cursor.execute("UPDATE positions SET key_word_id = '" + str(key_word_id) + "',position = '" + str(position) + "',day = '" + day + "',month = '" + month + "',year = '" + year + "' WHERE id="+id)
def geiipfromcity(self,city_id): '''Get IP-address around the city''' sql="SELECT ip FROM `ip_addresses` WHERE city_id=%s ORDER BY RAND() LIMIT 1" %city_id self.cursor.execute(sql) result=self.cursor.fetchall() if MysqlProvider._getrowcount(self)==0: sql="SELECT ip FROM `ip_addresses` ORDER BY RAND() LIMIT 1" self.cursor.execute(sql) result=self.cursor.fetchall() return result[0]['ip']
def geiipfromcity(self, city_id): '''Get IP-address around the city''' sql = "SELECT ip FROM `ip_addresses` WHERE city_id=%s ORDER BY RAND() LIMIT 1" % city_id self.cursor.execute(sql) result = self.cursor.fetchall() if MysqlProvider._getrowcount(self) == 0: sql = "SELECT ip FROM `ip_addresses` ORDER BY RAND() LIMIT 1" self.cursor.execute(sql) result = self.cursor.fetchall() return result[0]['ip']
def insertposition(self, key_word_id, position, day, month, year): '''Insert position google output''' self.cursor.execute( "SELECT * FROM google_positions WHERE key_word_id = '" + str(key_word_id) + "' AND position = '" + str(position) + "' AND day = '" + day + "' AND month = '" + month + "' AND year = '" + year + "'") if MysqlProvider._getrowcount(self) == 0: self.cursor.execute( "INSERT INTO google_positions SET key_word_id = '" + str(key_word_id) + "',position = '" + str(position) + "',day = '" + day + "',month = '" + month + "',year = '" + year + "'")
def insertpositionforce(self, key_word_id, position, day, month, year): '''Insert position google output (force)''' self.cursor.execute( "SELECT * FROM google_positions WHERE key_word_id = '" + str(key_word_id) + "' AND position = '" + str(position) + "' AND day = '" + day + "' AND month = '" + month + "' AND year = '" + year + "'") if MysqlProvider._getrowcount(self) == 0: GoogleMysqlProvider.insertposition(self, key_word_id, position, day, month, year) else: result = self.cursor.fetchall() id = result[0]['id'] self.cursor.execute("UPDATE google_positions SET key_word_id = '" + str(key_word_id) + "',position = '" + str(position) + "',day = '" + day + "',month = '" + month + "',year = '" + year + "' WHERE id=" + id)
def insertposition(self,key_word_id,position,day,month,year): '''Insert position google output''' self.cursor.execute("SELECT * FROM google_positions WHERE key_word_id = '" + str(key_word_id) + "' AND position = '" + str(position) + "' AND day = '" + day + "' AND month = '" + month + "' AND year = '" + year + "'") if MysqlProvider._getrowcount(self)==0: self.cursor.execute("INSERT INTO google_positions SET key_word_id = '" + str(key_word_id) + "',position = '" + str(position) + "',day = '" + day + "',month = '" + month + "',year = '" + year + "'")