-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdatePlayerTeams.py
More file actions
14 lines (14 loc) · 929 Bytes
/
updatePlayerTeams.py
File metadata and controls
14 lines (14 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import sqlite3
def update(date):
mydb = sqlite3.connect("CSGO-Results.db")
cursor = mydb.cursor()
cursor.execute("SELECT PlayerID FROM Player")
for each in cursor.fetchall():
playerID = each[0]
cursor.execute("SELECT TeamID,MAX(CountedTeam) FROM (SELECT TeamMap.TeamID TeamID,count(TeamMap.TeamID) CountedTeam FROM (SELECT PlayerMap.GameMapID PlayerMapGameID,PlayerID FROM PlayerMap,GameMap,Game WHERE PlayerID = ? AND PlayerMap.GameMapID = GameMap.GameMapID AND GameMap.GameID = Game.GameID AND Game.Date > ?),TeamMap WHERE TeamMap.GameMapID = PlayerMapGameID GROUP BY TeamMap.TeamID)",(playerID,date))
#Above counts each team a player has played for and for how many times.
teamID = cursor.fetchall()[0][0]
if teamID == None:
teamID=0
cursor.execute("UPDATE Player SET TeamID = (?) WHERE PlayerID = (?)",(teamID,playerID))
cursor.execute("COMMIT")