Ejemplo n.º 1
0
def query_ign():
    db = tools.db_connect()
    cursor = db.cursor()
    check_file = open('check.txt', 'a')
    try:
        sql = r"SELECT * FROM twitter_entity WHERE description LIKE '% summoner name : %' OR description LIKE '% summoner name: %' OR description LIKE '% IGN: %' OR description LIKE '% in game name: %' OR description LIKE '% lol name: %' OR description LIKE '% league of legends username: %' OR description LIKE '% league of legends name: %' OR description LIKE '% IGN : %' OR description LIKE '% Find me IG: %'"
        print sql
        cursor.execute(sql)
        data = cursor.fetchall()
        print len(data), " results"
        counter = 0
        for twitter_entity in data:
            res = resolve(twitter_entity)
            if res is -1:
                check_file.write(str(twitter_entity))
                print "player does not exist"
            else:
                insert_id = insert_entity(res, cursor, db)
                insert_resolution(insert_id, twitter_entity[0], cursor, db)

                counter += 1

            print "\n --END--\n"
            time.sleep(2)

    except MySQLdb.MySQLError as e:
        print "Error: unable to fetch data: ", e
    print "resolved: ", counter
    db.close()
Ejemplo n.º 2
0
def query_ign():
    db = tools.db_connect()
    cursor = db.cursor()
    check_file = open('check.txt', 'a')
    try:
        sql = r"SELECT * FROM twitter_entity WHERE description LIKE '% summoner name : %' OR description LIKE '% summoner name: %' OR description LIKE '% IGN: %' OR description LIKE '% in game name: %' OR description LIKE '% lol name: %' OR description LIKE '% league of legends username: %' OR description LIKE '% league of legends name: %' OR description LIKE '% IGN : %' OR description LIKE '% Find me IG: %'"
        print sql
        cursor.execute(sql)
        data = cursor.fetchall()
        print len(data), " results"
        counter = 0
        for twitter_entity in data:
            res = resolve(twitter_entity)
            if res is -1:
                check_file.write(str(twitter_entity))
                print "player does not exist"
            else:
                insert_id = insert_entity(res, cursor, db)
                insert_resolution(insert_id, twitter_entity[0], cursor, db)

                counter += 1

            print "\n --END--\n"
            time.sleep(2)



    except MySQLdb.MySQLError as e:
        print "Error: unable to fetch data: ", e
    print "resolved: ", counter
    db.close()
Ejemplo n.º 3
0
def update_tweets(tweets,loud=False):
	if tweets is not None:

		#create a new connection  
		firstTweet = tweets[0].id
		currentTweet = firstTweet
		try:
			upDTime = time.clock()
			tdb = tools.db_connect()
			emmcurs = tdb.cursor()
			count = 0
			for tweet in tweets:
				update_script = tweet.get_query(loud)
				emmcurs.execute(update_script)
				currentTweet = tweet.id
				count += 1
				if(count % 250):
					tdb.commit()
					count = 0
			tdb.commit()
			emmcurs.close()
			
		except Error as e:
			print "Updating tweets: ", (currentTweet), " failed."
			print "Message: ", e
			tdb.rollback()
Ejemplo n.º 4
0
	def __init__(self, loud=False):
		self.loud = loud
		t0 = time.clock()

		self.db = tools.db_connect()
		#Fire up three cursors - these should allow for threading.
		self.selcur = self.db.cursor()  #for selecting users
		
		self.last_update = time.clock()
		print str(time.clock() - t0) + " to connect for __init__."
Ejemplo n.º 5
0
	def __init__(self, loud=False):
		
		self.loud = loud
		self.t0 = time.clock()
		
		self.est_connections()
		self.db = tools.db_connect()
		#cursors
		self.selcur = self.db.cursor()
		self.inscur = self.db.cursor()
		self.tweets_counted = 0
		self.last_update = time.clock()
		self.cumulative = 0
		print str(self.update_clock()) + " to connect for __init__."
    def __init__(self, loud=False):

        self.loud = loud
        self.t0 = time.clock()

        self.est_connections()
        self.db = tools.db_connect()
        #cursors
        self.selcur = self.db.cursor()
        self.inscur = self.db.cursor()
        self.tweets_counted = 0
        self.last_update = time.clock()
        self.cumulative = 0
        print str(self.update_clock()) + " to connect for __init__."
Ejemplo n.º 7
0
def entity_min_max_update(row):
	#create a new connection  
	try:
		upDTime = time.clock()
		tdb = tools.db_connect()
		emmcurs = tdb.cursor()
		
		update_script = "UPDATE twitter_entity INNER JOIN (SELECT twitter_id, MIN(tweet_id) mintweet FROM tweets GROUP BY twitter_id) tb ON tb.twitter_id = twitter_entity.twitter_id SET twitter_entity.smallest_pulled_tweet_id = tb.mintweet WHERE twitter_entity.twitter_id = " + str(row[0]) + ";"
		emmcurs.execute(update_script)
		tdb.commit()
		
		update_script = "UPDATE twitter_entity INNER JOIN (SELECT twitter_id, MAX(tweet_id) maxtweet FROM tweets GROUP BY twitter_id) tb ON tb.twitter_id = twitter_entity.twitter_id SET twitter_entity.highest_pulled_tweet_id = tb.maxtweet WHERE twitter_entity.twitter_id = " + str(row[0]) + ";"
		emmcurs.execute(update_script)
		tdb.commit()

		emmcurs.close()
		print "Updated table's minmax! " + str(row[0]) 
		
	except Error as e:
		print "user update failed."
		print "Message: ", e
		tdb.rollback()
def entity_min_max_update(row):
    #create a new connection
    try:
        upDTime = time.clock()
        tdb = tools.db_connect()
        emmcurs = tdb.cursor()

        update_script = "UPDATE twitter_entity INNER JOIN (SELECT twitter_id, MIN(tweet_id) mintweet FROM tweets GROUP BY twitter_id) tb ON tb.twitter_id = twitter_entity.twitter_id SET twitter_entity.smallest_pulled_tweet_id = tb.mintweet WHERE twitter_entity.twitter_id = " + str(
            row[0]) + ";"
        emmcurs.execute(update_script)
        tdb.commit()

        update_script = "UPDATE twitter_entity INNER JOIN (SELECT twitter_id, MAX(tweet_id) maxtweet FROM tweets GROUP BY twitter_id) tb ON tb.twitter_id = twitter_entity.twitter_id SET twitter_entity.highest_pulled_tweet_id = tb.maxtweet WHERE twitter_entity.twitter_id = " + str(
            row[0]) + ";"
        emmcurs.execute(update_script)
        tdb.commit()

        emmcurs.close()
        print "Updated table's minmax! " + str(row[0])

    except Error as e:
        print "user update failed."
        print "Message: ", e
        tdb.rollback()
 def __init__(self):
     self.api = tools.api_connect()
     self.db = tools.db_connect()
     self.cursor_followers = tweepy.Cursor(
         self.api.followers, screen_name="LeagueOfLegends").items()
Ejemplo n.º 10
0
 def __init__(self):
     self.api = tools.api_connect()
     self.db = tools.db_connect()
     self.cursor_followers = tweepy.Cursor(self.api.followers, screen_name="LeagueOfLegends").items()
Ejemplo n.º 11
0
def get_matches(lol_entity_id, s_id,  db, cursor):
    rw = tools.lol_connect()

    try:
        stats = rw.get_match_list(s_id)
        if 'matches' not in stats:
            return
        stats = tools.unicode_to_utf8(stats)
        for match in stats['matches']:
            match_id = match['matchId']
            champion = match['champion']
            season = match['season']
            queue = match['queue']
            role = match['role']
            timestamp = match['timestamp']
            #print match_id, champion, season, queue, role, timestamp, lol_entity_id
            insert_match(match_id, champion, season, queue, role, timestamp, lol_entity_id, cursor, db)
        print "inserted for: ", lol_entity_id
    except LoLException as e:
        return -1

    return stats


db = tools.db_connect()
cursor = db.cursor()
entity_and_user_ids = get_lol_entities(db, cursor)

for id in entity_and_user_ids:
    # print "inserting: ", id[0], id[1]
    get_matches(id[0], id[1], db, cursor)
Ejemplo n.º 12
0
    rw = tools.lol_connect()

    try:
        stats = rw.get_match_list(s_id)
        if 'matches' not in stats:
            return
        stats = tools.unicode_to_utf8(stats)
        for match in stats['matches']:
            match_id = match['matchId']
            champion = match['champion']
            season = match['season']
            queue = match['queue']
            role = match['role']
            timestamp = match['timestamp']
            #print match_id, champion, season, queue, role, timestamp, lol_entity_id
            insert_match(match_id, champion, season, queue, role, timestamp,
                         lol_entity_id, cursor, db)
        print "inserted for: ", lol_entity_id
    except LoLException as e:
        return -1

    return stats


db = tools.db_connect()
cursor = db.cursor()
entity_and_user_ids = get_lol_entities(db, cursor)

for id in entity_and_user_ids:
    # print "inserting: ", id[0], id[1]
    get_matches(id[0], id[1], db, cursor)