2 # -*- coding: utf-8 -*-
14 print("Creating "+leaguename
+" Database.")
16 if(len(sys
.argv
) == 0):
17 sqlcon
= sqlite3
.connect("./ahl15-16.db3")
18 if(len(sys
.argv
) > 0):
19 sqlcon
= sqlite3
.connect(sys
.argv
[1])
20 sqlcur
= sqlcon
.cursor()
22 sqlcon
.execute("PRAGMA encoding = \"UTF-8\";")
23 sqlcon
.execute("PRAGMA auto_vacuum = 1;")
24 sqlcon
.execute("PRAGMA foreign_keys = 1;")
27 def GetLastTenGames(sqldatacon
, teamname
):
32 getlastninegames
= sqldatacon
[0].execute("SELECT NumberPeriods, TeamWin FROM "+leaguename
+"Games WHERE (HomeTeam=\""+str(
33 teamname
)+"\" OR AwayTeam=\""+str(teamname
)+"\") ORDER BY id DESC LIMIT 10").fetchall()
34 nmax
= len(getlastninegames
)
37 if(teamname
== str(getlastninegames
[nmin
][1])):
39 if(teamname
!= str(getlastninegames
[nmin
][1])):
40 if(int(getlastninegames
[nmin
][0]) == 3):
42 if(int(getlastninegames
[nmin
][0]) > 3):
43 otlosses
= otlosses
+ 1
45 return str(wins
)+":"+str(losses
)+":"+str(otlosses
)
48 def UpdateTeamData(sqldatacon
, teamid
, dataname
, addtodata
, addtype
):
53 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM " +
54 leaguename
+"Teams WHERE id="+str(teamid
)).fetchone()[0]) + addtodata
56 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM " +
57 leaguename
+"Teams WHERE id="+str(teamid
)).fetchone()[0]) - addtodata
58 sqldatacon
[0].execute("UPDATE "+leaguename
+"Teams SET " +
59 dataname
+"="+str(TMPData
)+" WHERE id="+str(teamid
))
63 def UpdateTeamDataString(sqldatacon
, teamid
, dataname
, newdata
):
65 sqldatacon
[0].execute("UPDATE "+leaguename
+"Teams SET " +
66 dataname
+"=\""+str(newdata
)+"\" WHERE id="+str(teamid
))
70 def GetTeamData(sqldatacon
, teamid
, dataname
, datatype
):
72 if(datatype
== "float"):
73 TMPData
= float(sqldatacon
[0].execute(
74 "SELECT "+dataname
+" FROM "+leaguename
+"Teams WHERE id="+str(teamid
)).fetchone()[0])
75 if(datatype
== "int"):
76 TMPData
= int(sqldatacon
[0].execute(
77 "SELECT "+dataname
+" FROM "+leaguename
+"Teams WHERE id="+str(teamid
)).fetchone()[0])
78 if(datatype
== "str"):
79 TMPData
= str(sqldatacon
[0].execute(
80 "SELECT "+dataname
+" FROM "+leaguename
+"Teams WHERE id="+str(teamid
)).fetchone()[0])
84 def UpdateGameData(sqldatacon
, gameid
, dataname
, addtodata
, addtype
):
89 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM " +
90 leaguename
+"Games WHERE id="+str(gameid
)).fetchone()[0]) + addtodata
92 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM " +
93 leaguename
+"Games WHERE id="+str(gameid
)).fetchone()[0]) - addtodata
94 sqldatacon
[0].execute("UPDATE "+leaguename
+"Games SET " +
95 dataname
+"="+str(TMPData
)+" WHERE id="+str(gameid
))
99 def UpdateGameDataString(sqldatacon
, gameid
, dataname
, newdata
):
101 sqldatacon
[0].execute("UPDATE "+leaguename
+"Games SET " +
102 dataname
+"=\""+str(newdata
)+"\" WHERE id="+str(gameid
))
106 def GetGameData(sqldatacon
, gameid
, dataname
, datatype
):
108 if(datatype
== "float"):
109 TMPData
= float(sqldatacon
[0].execute(
110 "SELECT "+dataname
+" FROM "+leaguename
+"Games WHERE id="+str(gameid
)).fetchone()[0])
111 if(datatype
== "int"):
112 TMPData
= int(sqldatacon
[0].execute(
113 "SELECT "+dataname
+" FROM "+leaguename
+"Games WHERE id="+str(gameid
)).fetchone()[0])
114 if(datatype
== "str"):
115 TMPData
= str(sqldatacon
[0].execute(
116 "SELECT "+dataname
+" FROM "+leaguename
+"Games WHERE id="+str(gameid
)).fetchone()[0])
120 def UpdateArenaData(sqldatacon
, arenaid
, dataname
, addtodata
, addtype
):
125 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM " +
126 leaguename
+"Arenas WHERE id="+str(arenaid
)).fetchone()[0]) + addtodata
128 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM " +
129 leaguename
+"Arenas WHERE id="+str(arenaid
)).fetchone()[0]) - addtodata
130 sqldatacon
[0].execute("UPDATE "+leaguename
+"Arenas SET " +
131 dataname
+"="+str(TMPData
)+" WHERE id="+str(arenaid
))
135 def UpdateArenaDataString(sqldatacon
, arenaid
, dataname
, newdata
):
137 sqldatacon
[0].execute("UPDATE "+leaguename
+"Arenas SET " +
138 dataname
+"=\""+str(newdata
)+"\" WHERE id="+str(arenaid
))
142 def GetArenaData(sqldatacon
, arenaid
, dataname
, datatype
):
144 if(datatype
== "float"):
145 TMPData
= float(sqldatacon
[0].execute(
146 "SELECT "+dataname
+" FROM "+leaguename
+"Arenas WHERE id="+str(arenaid
)).fetchone()[0])
147 if(datatype
== "int"):
148 TMPData
= int(sqldatacon
[0].execute(
149 "SELECT "+dataname
+" FROM "+leaguename
+"Arenas WHERE id="+str(arenaid
)).fetchone()[0])
150 if(datatype
== "str"):
151 TMPData
= str(sqldatacon
[0].execute(
152 "SELECT "+dataname
+" FROM "+leaguename
+"Arenas WHERE id="+str(arenaid
)).fetchone()[0])
156 def UpdateConferenceData(sqldatacon
, conference
, dataname
, addtodata
, addtype
):
161 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM "+leaguename
+
162 "Conferences WHERE Conference=\""+str(conference
)+"\"").fetchone()[0]) + addtodata
164 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM "+leaguename
+
165 "Conferences WHERE Conference=\""+str(conference
)+"\"").fetchone()[0]) - addtodata
166 sqldatacon
[0].execute("UPDATE "+leaguename
+"Conferences SET "+dataname
+
167 "="+str(TMPData
)+" WHERE Conference=\""+str(conference
)+"\"")
171 def UpdateDivisionData(sqldatacon
, division
, dataname
, addtodata
, addtype
):
176 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM "+leaguename
+
177 "Divisions WHERE Division=\""+str(division
)+"\"").fetchone()[0]) + addtodata
179 TMPData
= int(sqldatacon
[0].execute("SELECT "+dataname
+" FROM "+leaguename
+
180 "Divisions WHERE Division=\""+str(division
)+"\"").fetchone()[0]) - addtodata
181 sqldatacon
[0].execute("UPDATE "+leaguename
+"Divisions SET " +
182 dataname
+"="+str(TMPData
)+" WHERE Division=\""+str(division
)+"\"")
186 print("Creating "+leaguename
+" Conference Table.")
187 print("Inserting "+leaguename
+" Conference Data.")
189 sqlcon
.execute("DROP TABLE IF EXISTS "+leaguename
+"Conferences")
190 sqlcur
.execute("CREATE TABLE "+leaguename
+
191 "Conferences(id INTEGER PRIMARY KEY, Conference TEXT, NumberOfTeams INTEGER)")
195 def MakeHockeyConferences(sqldatacon
, conference
):
197 print("Conference Name: "+conference
)
199 sqldatacon
[0].execute("INSERT INTO "+leaguename
+
200 "Conferences(Conference, NumberOfTeams) VALUES(\""+str(conference
)+"\", 0)")
204 MakeHockeyConferences((sqlcur
, sqlcon
), "Eastern")
205 MakeHockeyConferences((sqlcur
, sqlcon
), "Western")
208 print("Creating "+leaguename
+" Division Table.")
209 print("Inserting "+leaguename
+" Division Data.")
211 sqlcon
.execute("DROP TABLE IF EXISTS "+leaguename
+"Divisions")
212 sqlcur
.execute("CREATE TABLE "+leaguename
+
213 "Divisions(id INTEGER PRIMARY KEY, Division TEXT, Conference TEXT, NumberOfTeams INTEGER)")
217 def MakeHockeyDivisions(sqldatacon
, division
, conference
):
219 print("Conference Name: "+conference
)
220 print("Division Name: "+division
)
222 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Divisions(Division, Conference, NumberOfTeams) VALUES(\"" +
223 str(division
)+"\", \""+str(conference
)+"\", 0)")
227 MakeHockeyDivisions((sqlcur
, sqlcon
), "Atlantic", "Eastern")
228 MakeHockeyDivisions((sqlcur
, sqlcon
), "North", "Eastern")
229 MakeHockeyDivisions((sqlcur
, sqlcon
), "Central", "Western")
230 MakeHockeyDivisions((sqlcur
, sqlcon
), "Pacific", "Western")
232 print("Creating "+leaguename
+" Team Table.")
233 print("Inserting "+leaguename
+" Team Data.")
235 sqlcon
.execute("DROP TABLE IF EXISTS "+leaguename
+"Arenas")
236 sqlcur
.execute("CREATE TABLE "+leaguename
+
237 "Arenas(id INTEGER PRIMARY KEY, CityName TEXT, AreaName TEXT, FullCityName TEXT, ArenaName TEXT, FullArenaName TEXT, GamesPlayed INTEGER)")
240 sqlcon
.execute("DROP TABLE IF EXISTS "+leaguename
+"Teams")
241 sqlcur
.execute("CREATE TABLE "+leaguename
+"Teams(id INTEGER PRIMARY KEY, Date INTEGER, FullName TEXT, CityName TEXT, TeamPrefix TEXT, AreaName TEXT, FullCityName TEXT, TeamName TEXT, Conference TEXT, Division TEXT, ArenaName TEXT, FullArenaName TEXT, Affiliates TEXT, GamesPlayed INTEGER, GamesPlayedHome INTEGER, GamesPlayedAway INTEGER, Wins INTEGER, OTWins INTEGER, SOWins INTEGER, OTSOWins INTEGER, TWins INTEGER, Losses INTEGER, OTLosses INTEGER, SOLosses INTEGER, OTSOLosses INTEGER, TLosses INTEGER, ROW INTEGER, ROT INTEGER, ShutoutWins INTEGER, ShutoutLosses INTEGER, HomeRecord TEXT, AwayRecord TEXT, Shootouts TEXT, GoalsFor INTEGER, GoalsAgainst INTEGER, GoalsDifference INTEGER, SOGFor INTEGER, SOGAgainst INTEGER, SOGDifference INTEGER, ShotsBlockedFor INTEGER, ShotsBlockedAgainst INTEGER, ShotsBlockedDifference INTEGER, Points INTEGER, PCT REAL, LastTen TEXT, Streak TEXT)")
242 sqlcon
.execute("DROP TABLE IF EXISTS "+leaguename
+"Stats")
243 sqlcur
.execute("CREATE TABLE "+leaguename
+"Stats(id INTEGER PRIMARY KEY, TeamID INTEGER, Date INTEGER, FullName TEXT, CityName TEXT, TeamPrefix TEXT, AreaName TEXT, FullCityName TEXT, TeamName TEXT, Conference TEXT, Division TEXT, ArenaName TEXT, FullArenaName TEXT, Affiliates TEXT, GamesPlayed INTEGER, GamesPlayedHome INTEGER, GamesPlayedAway INTEGER, Wins INTEGER, OTWins INTEGER, SOWins INTEGER, OTSOWins INTEGER, TWins INTEGER, Losses INTEGER, OTLosses INTEGER, SOLosses INTEGER, OTSOLosses INTEGER, TLosses INTEGER, ROW INTEGER, ROT INTEGER, ShutoutWins INTEGER, ShutoutLosses INTEGER, HomeRecord TEXT, AwayRecord TEXT, Shootouts TEXT, GoalsFor INTEGER, GoalsAgainst INTEGER, GoalsDifference INTEGER, SOGFor INTEGER, SOGAgainst INTEGER, SOGDifference INTEGER, ShotsBlockedFor INTEGER, ShotsBlockedAgainst INTEGER, ShotsBlockedDifference INTEGER, Points INTEGER, PCT REAL, LastTen TEXT, Streak TEXT)")
247 def MakeHockeyTeams(sqldatacon
, cityname
, areaname
, teamname
, conference
, division
, arenaname
, teamnameprefix
, teamaffiliates
):
249 print("Team Name: "+teamname
)
250 print("Arena Name: "+arenaname
)
251 print("City Name: "+cityname
)
252 print("Full City Name: "+cityname
+", "+areaname
)
253 print("Full Name: "+teamnameprefix
+" "+teamname
)
254 print("Conference: "+conference
)
255 print("Division: "+division
)
257 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Teams(Date, FullName, CityName, TeamPrefix, AreaName, FullCityName, TeamName, Conference, Division, ArenaName, FullArenaName, Affiliates, GamesPlayed, GamesPlayedHome, GamesPlayedAway, Wins, OTWins, SOWins, OTSOWins, TWins, Losses, OTLosses, SOLosses, OTSOLosses, TLosses, ROW, ROT, ShutoutWins, ShutoutLosses, HomeRecord, AwayRecord, Shootouts, GoalsFor, GoalsAgainst, GoalsDifference, SOGFor, SOGAgainst, SOGDifference, ShotsBlockedFor, ShotsBlockedAgainst, ShotsBlockedDifference, Points, PCT, LastTen, Streak) VALUES(\"20151001\", \"" +
258 str(teamnameprefix
+" "+teamname
)+"\", \""+str(cityname
)+"\", \""+str(teamnameprefix
)+"\", \""+str(areaname
)+"\", \""+str(cityname
+", "+areaname
)+"\", \""+str(teamname
)+"\", \""+str(conference
)+"\", \""+str(division
)+"\", \""+str(arenaname
)+"\", \""+str(arenaname
+", "+cityname
)+"\", \""+str(teamaffiliates
)+"\", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \"0:0:0\", \"0:0:0\", \"0:0\", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \"0:0:0\", \"None\")")
259 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Stats (TeamID, Date, FullName, CityName, TeamPrefix, AreaName, FullCityName, TeamName, Conference, Division, ArenaName, FullArenaName, Affiliates, GamesPlayed, GamesPlayedHome, GamesPlayedAway, Wins, OTWins, SOWins, OTSOWins, TWins, Losses, OTLosses, SOLosses, OTSOLosses, TLosses, ROW, ROT, ShutoutWins, ShutoutLosses, HomeRecord, AwayRecord, Shootouts, GoalsFor, GoalsAgainst, GoalsDifference, SOGFor, SOGAgainst, SOGDifference, ShotsBlockedFor, ShotsBlockedAgainst, ShotsBlockedDifference, Points, PCT, LastTen, Streak) SELECT id, Date, FullName, CityName, TeamPrefix, AreaName, FullCityName, TeamName, Conference, Division, ArenaName, FullArenaName, Affiliates, GamesPlayed, GamesPlayedHome, GamesPlayedAway, Wins, OTWins, SOWins, OTSOWins, TWins, Losses, OTLosses, SOLosses, OTSOLosses, TLosses, ROW, ROT, ShutoutWins, ShutoutLosses, HomeRecord, AwayRecord, Shootouts, GoalsFor, GoalsAgainst, GoalsDifference, SOGFor, SOGAgainst, SOGDifference, ShotsBlockedFor, ShotsBlockedAgainst, ShotsBlockedDifference, Points, PCT, LastTen, Streak FROM "+leaguename
+"Teams WHERE FullName=\""+teamnameprefix
+" "+teamname
+"\";")
260 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Arenas(CityName, AreaName, FullCityName, ArenaName, FullArenaName, GamesPlayed) VALUES(\""+str(
261 cityname
)+"\", \""+str(areaname
)+"\", \""+str(cityname
+", "+areaname
)+"\", \""+str(arenaname
)+"\", \""+str(arenaname
+", "+cityname
)+"\", 0)")
262 UpdateConferenceData((sqlcur
, sqlcon
), conference
, "NumberOfTeams", 1, "+")
263 UpdateDivisionData((sqlcur
, sqlcon
), division
, "NumberOfTeams", 1, "+")
267 def MakeHockeyArena(sqldatacon
, cityname
, areaname
, arenaname
, teamnameprefix
):
269 print("Arena Name: "+arenaname
)
270 print("City Name: "+cityname
)
271 print("Full City Name: "+cityname
+", "+areaname
)
273 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Arenas(CityName, AreaName, FullCityName, ArenaName, FullArenaName, GamesPlayed) VALUES(\""+str(
274 cityname
)+"\", \""+str(areaname
)+"\", \""+str(cityname
+", "+areaname
)+"\", \""+str(arenaname
)+"\", \""+str(arenaname
+", "+cityname
)+"\", 0)")
278 print("Inserting "+leaguename
+" Teams From Eastern Conference.")
279 print("Inserting "+leaguename
+" Teams From Atlantic Division.\n")
280 MakeHockeyTeams((sqlcur
, sqlcon
), "Bridgeport", "CT", "Sound Tigers", "Eastern", "Atlantic",
281 "Webster Bank Arena", "Bridgeport", "ECHL:Missouri Mavericks,NHL:New York Islanders")
282 MakeHockeyTeams((sqlcur
, sqlcon
), "Hartford", "CT", "Wolf Pack", "Eastern", "Atlantic",
283 "XL Center", "Hartford", "ECHL:Greenville Swamp Rabbits,NHL:New York Rangers")
284 MakeHockeyTeams((sqlcur
, sqlcon
), "Hershey", "PA", "Bears", "Eastern", "Atlantic",
285 "Giant Center", "Hershey", "ECHL:South Carolina Stingrays,NHL:Washington Capitals")
286 MakeHockeyTeams((sqlcur
, sqlcon
), "Allentown", "PA", "Phantoms", "Eastern", "Atlantic",
287 "PPL Center", "Lehigh Valley", "ECHL:Reading Royals,NHL:Philadelphia Flyers")
288 MakeHockeyTeams((sqlcur
, sqlcon
), "Portland", "ME", "Pirates", "Eastern", "Atlantic",
289 "Cross Insurance Arena", "Portland", "ECHL:None,NHL:Florida Panthers")
290 MakeHockeyTeams((sqlcur
, sqlcon
), "Providence", "RI", "Bruins", "Eastern", "Atlantic",
291 "Dunkin' Donuts Center", "Providence", "ECHL:Atlanta Gladiators,NHL:Boston Bruins")
292 MakeHockeyTeams((sqlcur
, sqlcon
), "Springfield", "MA", "Falcons", "Eastern", "Atlantic",
293 "MassMutual Center", "Springfield", "ECHL:Rapid City Rush,NHL:Arizona Coyotes")
294 MakeHockeyTeams((sqlcur
, sqlcon
), "Wilkes-Barre", "PA", "Penguins", "Eastern", "Atlantic",
295 "Mohegan Sun Arena", "Wilkes-Barre/Scranton", "ECHL:Wheeling Nailers,NHL:Pittsburgh Penguins")
297 print("Inserting "+leaguename
+" Teams From North Division.\n")
298 MakeHockeyTeams((sqlcur
, sqlcon
), "Albany", "NY", "Devils", "Eastern", "North",
299 "Times Union Center", "Albany", "ECHL:None,NHL:New Jersey Devils")
300 MakeHockeyTeams((sqlcur
, sqlcon
), "Binghamton", "NY", "Senators", "Eastern", "North",
301 "Floyd L. Maines Veterans Memorial Arena", "Binghamton", "ECHL:Evansville IceMen,NHL:Ottawa Senators")
302 MakeHockeyTeams((sqlcur
, sqlcon
), "Rochester", "NY", "Americans", "Eastern", "North",
303 "Blue Cross Arena", "Rochester", "ECHL:Elmira Jackals,NHL:Buffalo Sabres")
304 MakeHockeyTeams((sqlcur
, sqlcon
), "St. John's", "NL", "IceCaps", "Eastern", "North",
305 "Mile One Centre", "St. John's", "ECHL:Brampton Beast,NHL:Montreal Canadiens")
306 MakeHockeyTeams((sqlcur
, sqlcon
), "Syracuse", "NY", "Crunch", "Eastern", "North",
307 "Oncenter War Memorial Arena", "Syracuse", "ECHL:None,NHL:Tampa Bay Lightning")
308 MakeHockeyTeams((sqlcur
, sqlcon
), "Toronto", "ON", "Marlies", "Eastern", "North",
309 "Ricoh Coliseum", "Toronto", "ECHL:Orlando Solar Bears,NHL: Toronto Maple Leafs")
310 MakeHockeyTeams((sqlcur
, sqlcon
), "Utica", "NY", "Comets", "Eastern", "North",
311 "Utica Memorial Auditorium", "Utica", "ECHL:None,NHL:Vancouver Canucks")
313 print("Inserting "+leaguename
+" Teams From Western Conference.")
314 print("Inserting "+leaguename
+" Teams From Central Division.\n")
315 MakeHockeyTeams((sqlcur
, sqlcon
), "Charlotte", "NC", "Checkers", "Western", "Central",
316 "Bojangles Coliseum", "Charlotte", "ECHL:Florida Everblades,NHL:Carolina Hurricanes")
317 MakeHockeyTeams((sqlcur
, sqlcon
), "Rosemont", "IL", "Wolves", "Western",
318 "Central", "Allstate Arena", "Chicago", "ECHL:None,NHL:St. Louis Blues")
319 MakeHockeyTeams((sqlcur
, sqlcon
), "Grand Rapids", "MI", "Griffins", "Western", "Central",
320 "Van Andel Arena", "Grand Rapids", "ECHL:Toledo Walleye,NHL:Detroit Red Wings")
321 MakeHockeyTeams((sqlcur
, sqlcon
), "Des Moines", "IA", "Wild", "Western", "Central",
322 "Wells Fargo Arena", "Iowa", "ECHL:Quad City Mallards,NHL:Minnesota Wild")
323 MakeHockeyTeams((sqlcur
, sqlcon
), "Cleveland", "OH", "Monsters", "Western", "Central",
324 "Quicken Loans Arena", "Lake Erie", "ECHL:Kalamazoo Wings,NHL:Columbus Blue Jackets")
325 MakeHockeyTeams((sqlcur
, sqlcon
), "Winnipeg", "MB", "Moose", "Western",
326 "Central", "MTS Centre", "Manitoba", "ECHL:Tulsa Oilers,NHL:Winnipeg Jets")
327 MakeHockeyTeams((sqlcur
, sqlcon
), "Milwaukee", "WI", "Admirals", "Western", "Central",
328 "BMO Harris Bradley Center", "Milwaukee", "ECHL:Cincinnati Cyclones,NHL:Nashville Predators")
329 MakeHockeyTeams((sqlcur
, sqlcon
), "Rockford", "IL", "IceHogs", "Western", "Central",
330 "BMO Harris Bank Center", "Rockford", "ECHL:Indy Fuel,NHL:Chicago Blackhawks")
332 print("Inserting "+leaguename
+" Teams From Pacific Division.\n")
333 MakeHockeyTeams((sqlcur
, sqlcon
), "Bakersfield", "CA", "Condors", "Western", "Pacific",
334 "Rabobank Arena", "Bakersfield", "ECHL:Norfolk Admirals,NHL:Edmonton Oilers")
335 MakeHockeyTeams((sqlcur
, sqlcon
), "Ontario", "CA", "Reign", "Western", "Pacific",
336 "Citizens Business Bank Arena", "Ontario", "ECHL:Manchester Monarchs,NHL:Los Angeles Kings")
337 MakeHockeyTeams((sqlcur
, sqlcon
), "San Antonio", "TX", "Rampage", "Western", "Pacific",
338 "AT&T Center", "San Antonio", "ECHL:Fort Wayne Komets,NHL:Colorado Avalanche")
339 MakeHockeyTeams((sqlcur
, sqlcon
), "San Diego", "CA", "Gulls", "Western", "Pacific",
340 "Valley View Casino Center", "San Diego", "ECHL:Utah Grizzlies,NHL:Anaheim Ducks")
341 MakeHockeyTeams((sqlcur
, sqlcon
), "San Jose", "CA", "Barracuda", "Western",
342 "Pacific", "SAP Center", "San Jose", "ECHL:Allen Americans,NHL:San Jose Sharks")
343 MakeHockeyTeams((sqlcur
, sqlcon
), "Stockton", "CA", "Heat", "Western", "Pacific",
344 "Stockton Arena", "Stockton", "ECHL:Adirondack Thunder,NHL:Calgary Flames")
345 MakeHockeyTeams((sqlcur
, sqlcon
), "Cedar Park", "TX", "Stars", "Western", "Pacific",
346 "Cedar Park Center", "Texas", "ECHL:Idaho Steelheads,NHL:Dallas Stars")
348 MakeHockeyArena((sqlcur
, sqlcon
), "West Sacramento",
349 "CA", "Raley Field", "West Sacramento")
353 def GetNum2Team(sqldatacon
, TeamNum
, ReturnVar
):
355 return str(sqldatacon
[0].execute("SELECT "+ReturnVar
+" FROM "+leaguename
+"Teams WHERE id="+str(TeamNum
)).fetchone()[0])
358 def GetTeam2Num(sqldatacon
, TeamName
):
360 return int(sqldatacon
[0].execute("SELECT id FROM "+leaguename
+"Teams WHERE FullName=\""+str(TeamName
)+"\"").fetchone()[0])
363 def GetNum2Arena(sqldatacon
, ArenaNum
, ReturnVar
):
365 return str(sqldatacon
[0].execute("SELECT "+ReturnVar
+" FROM "+leaguename
+"Arenas WHERE id="+str(ArenaNum
)).fetchone()[0])
368 def GetArena2Num(sqldatacon
, ArenaName
):
370 return int(sqldatacon
[0].execute("SELECT id FROM "+leaguename
+"Arenas WHERE FullArenaName=\""+str(ArenaName
)+"\"").fetchone()[0])
373 print("DONE! All Team Data Inserted.")
375 print("Creating "+leaguename
+" Game Table.")
377 sqlcon
.execute("DROP TABLE IF EXISTS "+leaguename
+"Games")
378 sqlcur
.execute("CREATE TABLE "+leaguename
+"Games(id INTEGER PRIMARY KEY, Date INTEGER, HomeTeam Text, AwayTeam Text, AtArena Text, TeamScorePeriods TEXT, TeamFullScore Text, ShotsOnGoal TEXT, FullShotsOnGoal TEXT, ShotsBlocked TEXT, FullShotsBlocked TEXT, NumberPeriods INTEGER, TeamWin Text, IsPlayOffGame INTEGER)")
382 def MakeHockeyGame(sqldatacon
, date
, hometeam
, awayteam
, periodsscore
, shotsongoal
, atarena
, isplayoffgame
):
385 if(isplayoffgame
== True):
387 if(isplayoffgame
== False):
389 periodssplit
= periodsscore
.split(",")
391 numberofperiods
= int(len(periodssplit
))
396 while(periodcounting
< numberofperiods
):
397 periodscoresplit
= periodssplit
[periodcounting
].split(":")
398 homeperiodscore
= homeperiodscore
+" "+str(periodscoresplit
[0])
399 awayperiodscore
= awayperiodscore
+" "+str(periodscoresplit
[1])
400 if(periodcounting
<= 3):
401 homescore
= homescore
+ int(periodscoresplit
[0])
402 awayscore
= awayscore
+ int(periodscoresplit
[1])
403 if(isplayoffgame
== True and periodcounting
> 3):
404 homescore
= homescore
+ int(periodscoresplit
[0])
405 awayscore
= awayscore
+ int(periodscoresplit
[1])
406 if(isplayoffgame
== False and periodcounting
> 3):
407 if(periodscoresplit
[0] > periodscoresplit
[1]):
408 homescore
= homescore
+ 1
409 if(periodscoresplit
[0] < periodscoresplit
[1]):
410 awayscore
= awayscore
+ 1
411 periodcounting
= periodcounting
+ 1
412 totalscore
= str(homescore
)+":"+str(awayscore
)
413 teamscores
= totalscore
.split(":")
414 shotsongoalsplit
= shotsongoal
.split(",")
415 periodssplits
= periodsscore
.split(",")
416 numberofsogperiods
= int(len(shotsongoalsplit
))
417 periodsogcounting
= 0
425 while(periodsogcounting
< numberofsogperiods
):
426 periodsogsplit
= shotsongoalsplit
[periodsogcounting
].split(":")
427 periodscoresplit
= periodssplits
[periodsogcounting
].split(":")
428 homesog
= homesog
+ int(periodsogsplit
[0])
429 homesb
= int(periodsogsplit
[0]) - int(periodscoresplit
[0])
430 hometsb
= homesb
+ hometsb
431 awaysog
= awaysog
+ int(periodsogsplit
[1])
432 awaysb
= int(periodsogsplit
[1]) - int(periodscoresplit
[1])
433 awaytsb
= awaysb
+ awaytsb
434 sbstr
= sbstr
+str(homesb
)+":"+str(awaysb
)+" "
435 periodsogcounting
= periodsogcounting
+ 1
436 sbstr
= sbstr
.rstrip()
437 sbstr
= sbstr
.replace(" ", ",")
438 tsbstr
= str(hometsb
)+":"+str(awaytsb
)
439 totalsog
= str(homesog
)+":"+str(awaysog
)
440 teamssog
= totalsog
.split(":")
441 hometeamname
= hometeam
442 hometeam
= GetTeam2Num(sqldatacon
, hometeam
)
443 awayteamname
= awayteam
444 awayteam
= GetTeam2Num(sqldatacon
, awayteam
)
447 atarenaname
= GetTeamData(sqldatacon
, hometeam
, "FullArenaName", "str")
448 if(isinstance(atarena
, int) and atarena
> 0):
449 atarenaname
= GetNum2Arena(sqldatacon
, atarena
, "FullArenaName")
450 if(isinstance(atarena
, str)):
451 atarenaname
= atarena
452 atarena
= GetArena2Num(sqldatacon
, atarenaname
)
453 print("Home Arena: "+str(atarenaname
))
454 print("Home Team: "+GetNum2Team(sqldatacon
, int(hometeam
), "FullName"))
455 print("Home Period Scores:"+homeperiodscore
)
456 print("Home Score: "+str(teamscores
[0]))
457 print("Away Team: "+GetNum2Team(sqldatacon
, int(awayteam
), "FullName"))
458 print("Away Period Scores:"+awayperiodscore
)
459 print("Away Score: "+str(teamscores
[1]))
460 print("Number Of Periods: "+str(numberofperiods
))
461 if(teamscores
[0] > teamscores
[1]):
462 print("Winning Team: "+GetNum2Team(sqldatacon
, int(hometeam
), "FullName"))
463 print("Losing Team: "+GetNum2Team(sqldatacon
, int(awayteam
), "FullName"))
464 losingteam
= awayteam
465 winningteam
= hometeam
466 winningteamname
= hometeamname
467 losingteamname
= awayteamname
468 if(teamscores
[0] < teamscores
[1]):
469 print("Winning Team: "+GetNum2Team(sqldatacon
, int(awayteam
), "FullName"))
470 print("Losing Team: "+GetNum2Team(sqldatacon
, int(hometeam
), "FullName"))
471 losingteam
= hometeam
472 winningteam
= awayteam
473 winningteamname
= awayteamname
474 losingteamname
= hometeamname
476 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Games(Date, HomeTeam, AwayTeam, AtArena, TeamScorePeriods, TeamFullScore, ShotsOnGoal, FullShotsOnGoal, ShotsBlocked, FullShotsBlocked, NumberPeriods, TeamWin, IsPlayOffGame) VALUES("+str(date
)+", \""+str(hometeamname
)+"\", \""+str(
477 awayteamname
)+"\", \""+str(atarenaname
)+"\", \""+str(periodsscore
)+"\", \""+str(totalscore
)+"\", \""+str(shotsongoal
)+"\", \""+str(totalsog
)+"\", \""+str(sbstr
)+"\", \""+str(tsbstr
)+"\", "+str(numberofperiods
)+", \""+str(winningteamname
)+"\", "+str(isplayoffgsql
)+")")
478 UpdateArenaData(sqldatacon
, atarena
, "GamesPlayed", 1, "+")
479 UpdateTeamData(sqldatacon
, hometeam
, "Date", int(date
), "=")
480 UpdateTeamData(sqldatacon
, hometeam
, "GamesPlayed", 1, "+")
481 UpdateTeamData(sqldatacon
, hometeam
, "GamesPlayedHome", 1, "+")
482 UpdateTeamData(sqldatacon
, hometeam
, "GoalsFor", int(teamscores
[0]), "+")
483 UpdateTeamData(sqldatacon
, hometeam
, "GoalsAgainst",
484 int(teamscores
[1]), "+")
485 UpdateTeamData(sqldatacon
, hometeam
, "GoalsDifference",
486 int(int(teamscores
[0]) - int(teamscores
[1])), "+")
487 UpdateTeamData(sqldatacon
, hometeam
, "SOGFor", int(teamssog
[0]), "+")
488 UpdateTeamData(sqldatacon
, hometeam
, "SOGAgainst", int(teamssog
[1]), "+")
489 UpdateTeamData(sqldatacon
, hometeam
, "SOGDifference",
490 int(int(teamssog
[0]) - int(teamssog
[1])), "+")
491 UpdateTeamData(sqldatacon
, hometeam
, "ShotsBlockedFor", int(hometsb
), "+")
492 UpdateTeamData(sqldatacon
, hometeam
,
493 "ShotsBlockedAgainst", int(awaytsb
), "+")
494 UpdateTeamData(sqldatacon
, hometeam
, "ShotsBlockedDifference",
495 int(int(hometsb
) - int(awaytsb
)), "+")
496 UpdateTeamData(sqldatacon
, awayteam
, "Date", int(date
), "=")
497 UpdateTeamData(sqldatacon
, awayteam
, "GamesPlayed", 1, "+")
498 UpdateTeamData(sqldatacon
, awayteam
, "GamesPlayedAway", 1, "+")
499 UpdateTeamData(sqldatacon
, awayteam
, "GoalsFor", int(teamscores
[1]), "+")
500 UpdateTeamData(sqldatacon
, awayteam
, "GoalsAgainst",
501 int(teamscores
[0]), "+")
502 UpdateTeamData(sqldatacon
, awayteam
, "GoalsDifference",
503 int(int(teamscores
[1]) - int(teamscores
[0])), "+")
504 UpdateTeamData(sqldatacon
, awayteam
, "SOGFor", int(teamssog
[1]), "+")
505 UpdateTeamData(sqldatacon
, awayteam
, "SOGAgainst", int(teamssog
[0]), "+")
506 UpdateTeamData(sqldatacon
, awayteam
, "SOGDifference",
507 int(int(teamssog
[1]) - int(teamssog
[0])), "+")
508 UpdateTeamData(sqldatacon
, awayteam
, "ShotsBlockedFor", int(awaytsb
), "+")
509 UpdateTeamData(sqldatacon
, awayteam
,
510 "ShotsBlockedAgainst", int(hometsb
), "+")
511 UpdateTeamData(sqldatacon
, awayteam
, "ShotsBlockedDifference",
512 int(int(awaytsb
) - int(hometsb
)), "+")
513 if(winningteam
== hometeam
and int(teamscores
[1]) == 0):
514 UpdateTeamData(sqldatacon
, hometeam
, "ShutoutWins", 1, "+")
515 UpdateTeamData(sqldatacon
, awayteam
, "ShutoutLosses", 1, "+")
516 if(winningteam
== awayteam
and int(teamscores
[0]) == 0):
517 UpdateTeamData(sqldatacon
, awayteam
, "ShutoutWins", 1, "+")
518 UpdateTeamData(sqldatacon
, hometeam
, "ShutoutLosses", 1, "+")
519 UpdateTeamDataString(sqldatacon
, winningteam
, "LastTen",
520 GetLastTenGames(sqldatacon
, winningteamname
))
521 UpdateTeamDataString(sqldatacon
, losingteam
, "LastTen",
522 GetLastTenGames(sqldatacon
, losingteamname
))
523 GetWinningStreak
= GetTeamData(sqldatacon
, winningteam
, "Streak", "str")
524 GetWinningStreakNext
= "Won 1"
525 if(GetWinningStreak
!= "None"):
526 GetWinningStreakSplit
= re
.findall(
527 "([a-zA-Z]+) ([0-9]+)", GetWinningStreak
)
528 if(GetWinningStreakSplit
[0][0] == "Won"):
529 GetWinningStreakNext
= "Won " + \
530 str(int(GetWinningStreakSplit
[0][1]) + 1)
531 if(GetWinningStreakSplit
[0][0] == "Lost"):
532 GetWinningStreakNext
= "Won 1"
533 if(GetWinningStreakSplit
[0][0] == "OT"):
534 GetWinningStreakNext
= "Won 1"
535 UpdateTeamDataString(sqldatacon
, winningteam
,
536 "Streak", GetWinningStreakNext
)
537 GetLosingStreak
= GetTeamData(sqldatacon
, losingteam
, "Streak", "str")
538 if(numberofperiods
== 3):
539 GetLosingStreakNext
= "Lost 1"
540 if(numberofperiods
> 3):
541 GetLosingStreakNext
= "OT 1"
542 if(GetLosingStreak
!= "None"):
543 GetLosingStreakSplit
= re
.findall(
544 "([a-zA-Z]+) ([0-9]+)", GetLosingStreak
)
545 if(GetLosingStreakSplit
[0][0] == "Won"):
546 if(numberofperiods
== 3):
547 GetLosingStreakNext
= "Lost 1"
548 if(numberofperiods
> 3):
549 GetLosingStreakNext
= "OT 1"
550 if(GetLosingStreakSplit
[0][0] == "Lost"):
551 if(numberofperiods
== 3):
552 GetLosingStreakNext
= "Lost " + \
553 str(int(GetLosingStreakSplit
[0][1]) + 1)
554 if(numberofperiods
> 3):
555 GetLosingStreakNext
= "OT 1"
556 if(GetLosingStreakSplit
[0][0] == "OS"):
557 if(numberofperiods
== 3):
558 GetLosingStreakNext
= "Lost 1"
559 if(numberofperiods
> 3):
560 GetLosingStreakNext
= "OT " + \
561 str(int(GetLosingStreakSplit
[0][1]) + 1)
562 UpdateTeamDataString(sqldatacon
, losingteam
, "Streak", GetLosingStreakNext
)
563 if((isplayoffgame
== False and numberofperiods
< 5) or (isplayoffgame
== True)):
564 UpdateTeamData(sqldatacon
, winningteam
, "ROW", 1, "+")
565 UpdateTeamData(sqldatacon
, losingteam
, "ROT", 1, "+")
566 if(numberofperiods
== 3):
567 UpdateTeamData(sqldatacon
, winningteam
, "Wins", 1, "+")
568 UpdateTeamData(sqldatacon
, winningteam
, "TWins", 1, "+")
569 UpdateTeamData(sqldatacon
, winningteam
, "Points", 2, "+")
570 UpdateTeamData(sqldatacon
, losingteam
, "Losses", 1, "+")
571 UpdateTeamData(sqldatacon
, losingteam
, "TLosses", 1, "+")
572 UpdateTeamData(sqldatacon
, losingteam
, "Points", 0, "+")
573 if(winningteam
== hometeam
):
574 HomeTeamRecord
= GetTeamData(
575 sqldatacon
, winningteam
, "HomeRecord", "str")
576 HTRSpit
= [int(n
) for n
in HomeTeamRecord
.split(":")]
577 NewHTR
= str(HTRSpit
[0] + 1)+":" + \
578 str(HTRSpit
[1])+":"+str(HTRSpit
[2])
579 UpdateTeamDataString(sqldatacon
, winningteam
, "HomeRecord", NewHTR
)
580 AwayTeamRecord
= GetTeamData(
581 sqldatacon
, losingteam
, "AwayRecord", "str")
582 ATRSpit
= [int(n
) for n
in AwayTeamRecord
.split(":")]
583 NewATR
= str(ATRSpit
[0])+":" + \
584 str(ATRSpit
[1] + 1)+":"+str(ATRSpit
[2])
585 UpdateTeamDataString(sqldatacon
, losingteam
, "AwayRecord", NewATR
)
586 if(losingteam
== hometeam
):
587 HomeTeamRecord
= GetTeamData(
588 sqldatacon
, winningteam
, "AwayRecord", "str")
589 HTRSpit
= [int(n
) for n
in HomeTeamRecord
.split(":")]
590 NewHTR
= str(HTRSpit
[0] + 1)+":" + \
591 str(HTRSpit
[1])+":"+str(HTRSpit
[2])
592 UpdateTeamDataString(sqldatacon
, winningteam
, "AwayRecord", NewHTR
)
593 AwayTeamRecord
= GetTeamData(
594 sqldatacon
, losingteam
, "HomeRecord", "str")
595 ATRSpit
= [int(n
) for n
in AwayTeamRecord
.split(":")]
596 NewATR
= str(ATRSpit
[0])+":" + \
597 str(ATRSpit
[1] + 1)+":"+str(ATRSpit
[2])
598 UpdateTeamDataString(sqldatacon
, losingteam
, "HomeRecord", NewATR
)
599 if(numberofperiods
> 3):
600 if((numberofperiods
== 4 and isplayoffgame
== False) or (numberofperiods
> 4 and isplayoffgame
== True)):
601 UpdateTeamData(sqldatacon
, winningteam
, "OTWins", 1, "+")
602 UpdateTeamData(sqldatacon
, winningteam
, "OTSOWins", 1, "+")
603 UpdateTeamData(sqldatacon
, winningteam
, "TWins", 1, "+")
604 UpdateTeamData(sqldatacon
, winningteam
, "Points", 2, "+")
605 if((numberofperiods
== 4 and isplayoffgame
== False) or (numberofperiods
> 4 and isplayoffgame
== True)):
606 UpdateTeamData(sqldatacon
, losingteam
, "OTLosses", 1, "+")
607 UpdateTeamData(sqldatacon
, losingteam
, "OTSOLosses", 1, "+")
608 UpdateTeamData(sqldatacon
, losingteam
, "TLosses", 1, "+")
609 UpdateTeamData(sqldatacon
, losingteam
, "Points", 1, "+")
610 if(winningteam
== hometeam
):
611 HomeTeamRecord
= GetTeamData(
612 sqldatacon
, winningteam
, "HomeRecord", "str")
613 HTRSpit
= [int(n
) for n
in HomeTeamRecord
.split(":")]
614 NewHTR
= str(HTRSpit
[0] + 1)+":" + \
615 str(HTRSpit
[1])+":"+str(HTRSpit
[2])
616 UpdateTeamDataString(sqldatacon
, winningteam
, "HomeRecord", NewHTR
)
617 AwayTeamRecord
= GetTeamData(
618 sqldatacon
, losingteam
, "AwayRecord", "str")
619 ATRSpit
= [int(n
) for n
in AwayTeamRecord
.split(":")]
620 NewATR
= str(ATRSpit
[0])+":"+str(ATRSpit
[1]) + \
621 ":"+str(ATRSpit
[2] + 1)
622 UpdateTeamDataString(sqldatacon
, losingteam
, "AwayRecord", NewATR
)
623 if(losingteam
== hometeam
):
624 HomeTeamRecord
= GetTeamData(
625 sqldatacon
, winningteam
, "AwayRecord", "str")
626 HTRSpit
= [int(n
) for n
in HomeTeamRecord
.split(":")]
627 NewHTR
= str(HTRSpit
[0] + 1)+":" + \
628 str(HTRSpit
[1])+":"+str(HTRSpit
[2])
629 UpdateTeamDataString(sqldatacon
, winningteam
, "AwayRecord", NewHTR
)
630 AwayTeamRecord
= GetTeamData(
631 sqldatacon
, losingteam
, "HomeRecord", "str")
632 ATRSpit
= [int(n
) for n
in AwayTeamRecord
.split(":")]
633 NewATR
= str(ATRSpit
[0])+":"+str(ATRSpit
[1]) + \
634 ":"+str(ATRSpit
[2] + 1)
635 UpdateTeamDataString(sqldatacon
, losingteam
, "HomeRecord", NewATR
)
636 if(isplayoffgame
== False and numberofperiods
> 4):
637 UpdateTeamData(sqldatacon
, winningteam
, "SOWins", 1, "+")
638 UpdateTeamData(sqldatacon
, losingteam
, "SOLosses", 1, "+")
639 WinningTeamShootouts
= GetTeamData(
640 sqldatacon
, winningteam
, "Shootouts", "str")
641 WTSoSplit
= [int(n
) for n
in WinningTeamShootouts
.split(":")]
642 NewWTSo
= str(WTSoSplit
[0] + 1)+":"+str(WTSoSplit
[1])
643 UpdateTeamDataString(sqldatacon
, winningteam
, "Shootouts", NewWTSo
)
644 LosingTeamShootouts
= GetTeamData(
645 sqldatacon
, losingteam
, "Shootouts", "str")
646 LTSoSplit
= [int(n
) for n
in LosingTeamShootouts
.split(":")]
647 NewLTSo
= str(LTSoSplit
[0])+":"+str(LTSoSplit
[1] + 1)
648 UpdateTeamDataString(sqldatacon
, losingteam
, "Shootouts", NewLTSo
)
649 HomeOTLossesPCT
= float("%.2f" % float(float(
650 0.5) * float(GetTeamData((sqlcur
, sqlcon
), hometeam
, "OTSOLosses", "float"))))
651 HomeWinsPCT
= float("%.3f" % float(float(GetTeamData((sqlcur
, sqlcon
), hometeam
, "TWins", "float") +
652 HomeOTLossesPCT
) / float(GetTeamData((sqlcur
, sqlcon
), hometeam
, "GamesPlayed", "float"))))
653 AwayOTLossesPCT
= float("%.2f" % float(float(
654 0.5) * float(GetTeamData((sqlcur
, sqlcon
), awayteam
, "OTSOLosses", "float"))))
655 AwayWinsPCT
= float("%.3f" % float(float(GetTeamData((sqlcur
, sqlcon
), awayteam
, "TWins", "float") +
656 AwayOTLossesPCT
) / float(GetTeamData((sqlcur
, sqlcon
), awayteam
, "GamesPlayed", "float"))))
657 UpdateTeamData(sqldatacon
, hometeam
, "PCT", HomeWinsPCT
, "=")
658 UpdateTeamData(sqldatacon
, awayteam
, "PCT", AwayWinsPCT
, "=")
659 sqldatacon
[1].commit()
660 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Stats (TeamID, Date, FullName, CityName, TeamPrefix, AreaName, FullCityName, TeamName, Conference, Division, ArenaName, FullArenaName, Affiliates, GamesPlayed, GamesPlayedHome, GamesPlayedAway, Wins, OTWins, SOWins, OTSOWins, TWins, Losses, OTLosses, SOLosses, OTSOLosses, TLosses, ROW, ROT, ShutoutWins, ShutoutLosses, HomeRecord, AwayRecord, Shootouts, GoalsFor, GoalsAgainst, GoalsDifference, SOGFor, SOGAgainst, SOGDifference, ShotsBlockedFor, ShotsBlockedAgainst, ShotsBlockedDifference, Points, PCT, LastTen, Streak) SELECT id, Date, FullName, CityName, TeamPrefix, AreaName, FullCityName, TeamName, Conference, Division, ArenaName, FullArenaName, Affiliates, GamesPlayed, GamesPlayedHome, GamesPlayedAway, Wins, OTWins, SOWins, OTSOWins, TWins, Losses, OTLosses, SOLosses, OTSOLosses, TLosses, ROW, ROT, ShutoutWins, ShutoutLosses, HomeRecord, AwayRecord, Shootouts, GoalsFor, GoalsAgainst, GoalsDifference, SOGFor, SOGAgainst, SOGDifference, ShotsBlockedFor, ShotsBlockedAgainst, ShotsBlockedDifference, Points, PCT, LastTen, Streak FROM "+leaguename
+"Teams WHERE FullName=\""+hometeamname
+"\";")
661 sqldatacon
[0].execute("INSERT INTO "+leaguename
+"Stats (TeamID, Date, FullName, CityName, TeamPrefix, AreaName, FullCityName, TeamName, Conference, Division, ArenaName, FullArenaName, Affiliates, GamesPlayed, GamesPlayedHome, GamesPlayedAway, Wins, OTWins, SOWins, OTSOWins, TWins, Losses, OTLosses, SOLosses, OTSOLosses, TLosses, ROW, ROT, ShutoutWins, ShutoutLosses, HomeRecord, AwayRecord, Shootouts, GoalsFor, GoalsAgainst, GoalsDifference, SOGFor, SOGAgainst, SOGDifference, ShotsBlockedFor, ShotsBlockedAgainst, ShotsBlockedDifference, Points, PCT, LastTen, Streak) SELECT id, Date, FullName, CityName, TeamPrefix, AreaName, FullCityName, TeamName, Conference, Division, ArenaName, FullArenaName, Affiliates, GamesPlayed, GamesPlayedHome, GamesPlayedAway, Wins, OTWins, SOWins, OTSOWins, TWins, Losses, OTLosses, SOLosses, OTSOLosses, TLosses, ROW, ROT, ShutoutWins, ShutoutLosses, HomeRecord, AwayRecord, Shootouts, GoalsFor, GoalsAgainst, GoalsDifference, SOGFor, SOGAgainst, SOGDifference, ShotsBlockedFor, ShotsBlockedAgainst, ShotsBlockedDifference, Points, PCT, LastTen, Streak FROM "+leaguename
+"Teams WHERE FullName=\""+awayteamname
+"\";")
662 sqldatacon
[1].commit()
666 print("Database Check Return: " +
667 str(sqlcon
.execute("PRAGMA integrity_check(100);").fetchone()[0])+"\n")
671 print("DONE! All Game Data Inserted.")
673 print("DONE! "+leaguename
+" Database Created.")