def getEstimates():
    #This method goes through, grabs the polls and sends them through the Kalman fitler for each candidate and returns all the arrays of estimates as two dictionaries.
    #First, we initialize our SQLite connection
    cursor = conn.cursor()
    #Next, we make sure that our polls are all up-to-date, and this also gives us a list of candidates for each party
    dems, repubs = PollFetcher.fetchPolls()
    demEstimates = {}
    demUncertainties = {}
    for d in dems:
        #We go through every candidate and first get the poll results from the database
        cursor.execute("SELECT EndDate, `%(cand)s`, Sample FROM DemPrimary;" %{"cand":d})
        polls = cursor.fetchall()
        #Next we send these polls through the KalmanFilter to get the estimates
        dates, estimates, uncertainties = KalmanFilter.kalman(polls)
        demEstimates[d] = [dates, estimates]
        demUncertainties[d] = [dates, uncertainties]
    #We now repeat the process for the Republicans
    repubEstimates = {}
    repubUncertainties = {}
    for r in repubs:
        cursor.execute("SELECT EndDate, `%(cand)s`, Sample FROM RepubPrimary;" %{"cand": r})
        polls = cursor.fetchall()
        dates, estimates, uncertainties = KalmanFilter.kalman(polls)
        repubEstimates[r] = [dates, estimates]
        repubUncertainties[r] = [dates, uncertainties]
    #We now return our estimates and uncertainties
    return demEstimates, demUncertainties, repubEstimates, repubUncertainties
def getEstimates():
    #This method goes through, grabs the polls and sends them through the Kalman fitler for each candidate and returns all the arrays of estimates as two dictionaries.
    #First, we initialize our MySQL connection
    mariadb_conn = mariadb.connect(user = username, passwd = passw, db = dbName)
    cursor = mariadb_conn.cursor()
    #Next, we make sure that our polls are all up-to-date, and this also gives us a list of candidates for each party
    dems, repubs = PollFetcher.fetchPolls()
    demEstimates = {}
    demUncertainties = {}
    for d in dems:
        #We go through every candidate and first get the poll results from the database
        cursor.execute("SELECT EndDate, `%(cand)s` FROM DemPrimary;" %{"cand":d})
        polls = cursor.fetchall()
        #Next we send these polls through the KalmanFilter to get the estimates
        x = [p[0] for p in polls]
        y = [p[1] for p in polls]
        polls = [x, y]
        demEstimates[d] = smoothEstimates(polls)
    #We now repeat the process for the Republicans
    repubEstimates = {}
    repubUncertainties = {}
    for r in repubs:
        cursor.execute("SELECT EndDate, `%(cand)s`, Sample FROM RepubPrimary;" %{"cand": r})
        polls = cursor.fetchall()
        x = [p[0] for p in polls]
        y = [p[1] for p in polls]
        polls = [x, y]
        repubEstimates[r] = smoothEstimates(polls)
    #We now return our estimates and uncertainties
    return demEstimates, repubEstimates