I don’t understand why team is placed between brackets runs = cur.execute(query, [team]).fetchall() Someone please explain
Code:
import sqlite3
memory = sqlite3.connect(':memory:') # create a memory database
disk = sqlite3.connect('lahman2015.sqlite')
dump = "".join([line for line in disk.iterdump() if "Batting" in line])
memory.executescript(dump)
cur = memory.cursor()
query = "SELECT SUM(HR) FROM Batting WHERE teamId=?"
def calculate_runs(teams):
home_runs = []
for team in teams:
runs = cur.execute(query, [team]).fetchall()
runs = runs[0][0]
home_runs.append(runs)
return home_runs
profile_string = "home_runs = calculate_runs(teams)"
cProfile.run(profile_string)