예제 #1
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def balans():
    db = db_connect('pythonsqlite.db')
    rowsb = db.execute("SELECT * FROM rekeningen WHERE userid = ? ",
                       (session["user_id"], ))
    rowb = rowsb.fetchall()
    balans = 0
    for row in rowb:
        if not row[2] == "smekkels":
            balans += row[1]
    rekeningtotaal = 0
    for row in rowb:
        if not row[2] == "smekkels" and not row[2] == "Cash":
            rekeningtotaal += row[1]
    # Bereken totaal van inkomsten en uitgaven aller tijden
    db = db_connect('pythonsqlite.db')
    selecteer = db.execute(
        "SELECT * FROM Transacties WHERE userid=? and Soort=?",
        (session["user_id"], "Inkomst"))
    inkomsten = selecteer.fetchall()
    alltimeinkomsten = 0
    for inkomst in inkomsten:
        alltimeinkomsten += inkomst[2]
    selecteer2 = db.execute(
        "SELECT * FROM Transacties WHERE userid=? and Soort=?",
        (session["user_id"], "Uitgave"))
    uitgaven = selecteer2.fetchall()
    alltimeuitgaven = 0
    for uitgave in uitgaven:
        alltimeuitgaven += uitgave[2]
        # Neem alle beleggingen van huidige user voor op pagina te zetten
        rowsb = db.execute("SELECT * FROM Beleggingen WHERE Userid = ?",
                           (session["user_id"], ))
        beleggingen = rowsb.fetchall()
    # Bereken totaal van alle portfolios: prijs en waarde
    totaalbeleggingen = 0
    totaalprijs = 0
    totaalverkocht = 0
    for row in beleggingen:
        totaalprijs += row[2]
        totaalbeleggingen += row[3]
        totaalverkocht += row[6]
    return render_template("balans.html",
                           totaalprijs=totaalprijs,
                           totaalbeleggingen=totaalbeleggingen,
                           totaalverkocht=totaalverkocht,
                           rekeningen=rowb,
                           totaal=balans,
                           rekeningtotaal=rekeningtotaal,
                           inkomsten=alltimeinkomsten,
                           uitgaven=alltimeuitgaven)
예제 #2
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def jaar():
    db = db_connect('pythonsqlite.db')
    dbU = db_connect('pythonsqlite.db')
    rowsI = db.execute(
        "SELECT * FROM Transacties WHERE userid=? AND soort='Inkomst'",
        (session["user_id"], ))
    rowsU = dbU.execute(
        "SELECT * FROM Transacties WHERE userid=? AND soort='Uitgave'",
        (session["user_id"], ))
    transacties = rowsI.fetchall()
    transactiesU = rowsU.fetchall()
    return render_template("jaar.html",
                           transacties=transacties,
                           Uitgaven=transactiesU,
                           date=time.strftime("%x"))
예제 #3
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def grafiek():
    db = db_connect('pythonsqlite.db')
    rows = db.execute(
        "SELECT * FROM Transacties WHERE userid=? AND soort='Uitgave'",
        (session["user_id"], ))
    uitgaven = rows.fetchall()
    # bereken totaal van inkomsten in huidige maand
    inkomst = db.execute(
        "SELECT * FROM Transacties WHERE userid=? and Soort=?",
        (session["user_id"], "Inkomst"))
    ink = inkomst.fetchall()
    # bereken totaal van uitgaven in huidige maand
    uitgave = db.execute(
        "SELECT * FROM Transacties WHERE userid=? and Soort=?",
        (session["user_id"], "Uitgave"))
    uit = uitgave.fetchall()
    hist = db.execute("SELECT * FROM Historiek WHERE userid=?",
                      (session["user_id"], ))
    history = hist.fetchall()
    return render_template("grafiek.html",
                           uitgaven=uitgaven,
                           ink=ink,
                           uit=uit,
                           date=time.strftime("%x"),
                           history=history)
예제 #4
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def verkoopbelegging():
    if request.method == "GET":
        db = db_connect('pythonsqlite.db')
        rowsb = db.execute("SELECT * FROM Portfolios WHERE userid = ? ",
                           (session["user_id"], ))
        portfolios = rowsb.fetchall()
        rowsb = db.execute("SELECT * FROM Rekeningen WHERE userid = ? ",
                           (session["user_id"], ))
        rekeningen = rowsb.fetchall()
        rowsb = db.execute("SELECT * FROM Beleggingen WHERE userid = ? ",
                           (session["user_id"], ))
        beleggingen = rowsb.fetchall()
        return render_template("verkoopbelegging.html",
                               portfolios=portfolios,
                               rekeningen=rekeningen,
                               beleggingen=beleggingen)
    else:
        conn = sqlite3.connect('pythonsqlite.db')
        db = conn.cursor()
        db.execute(
            'UPDATE Beleggingen SET verkocht=verkocht+? where naam=? AND userid=?',
            (request.form.get("verkocht"), request.form.get("belegging"),
             session["user_id"]))
        db.execute(
            'UPDATE rekeningen SET balans=balans+? where rekeningnaam=? AND userid=?',
            (request.form.get("bedrag"), request.form.get("rekening"),
             session["user_id"]))
        # commit changes
        conn.commit()
        return redirect("/beleggingen")
예제 #5
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def test():
    if request.method == "GET":
        db = db_connect('pythonsqlite.db')
        rows = db.execute("SELECT * FROM rekeningen WHERE userid = ? ",
                          (session["user_id"], ))
        rekeningen = rows.fetchall()
        return render_template("input.html", rekeningen=rekeningen)
    else:
        conn = sqlite3.connect('pythonsqlite.db')
        db = conn.cursor()
        # Insert transactie into database
        db.execute(
            "INSERT INTO Transacties (Userid, Naam, Bedrag, Datum, Rekening, Soort, Categorie, Subcategorie) VALUES(?,?,?,?,?,?,?,?)",
            (session["user_id"], request.form.get("name"),
             request.form.get("Hoeveelheid"), request.form.get("Datum"),
             request.form.get("rekening"), request.form.get("soort"),
             request.form.get("Categorie"), request.form.get("Subcategorie")))
        # commit changes
        conn.commit()
        rows = db.execute(
            "SELECT * FROM rekeningen where userid=? AND rekeningnaam=?",
            (session["user_id"], request.form.get("rekening")))
        balans = rows.fetchone()
        if request.form.get("soort") == "Uitgave":
            newbalans = balans[1] - float(request.form.get("Hoeveelheid"))
        else:
            newbalans = balans[1] + float(request.form.get("Hoeveelheid"))
        db.execute(
            "UPDATE rekeningen SET balans=? WHERE userid=? AND rekeningnaam=?",
            (newbalans, session["user_id"], request.form.get("rekening")))
        # commit changes
        conn.commit()
        return redirect("/home")
예제 #6
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def addbelegging():
    if request.method == "GET":
        db = db_connect('pythonsqlite.db')
        rowsb = db.execute("SELECT * FROM Portfolios WHERE userid = ? ",
                           (session["user_id"], ))
        portfolios = rowsb.fetchall()
        rowsb = db.execute("SELECT * FROM Rekeningen WHERE userid = ? ",
                           (session["user_id"], ))
        rekeningen = rowsb.fetchall()
        rowsb = db.execute("SELECT * FROM Beleggingen WHERE userid = ? ",
                           (session["user_id"], ))
        beleggingen = rowsb.fetchall()
        return render_template("addbelegging.html",
                               portfolios=portfolios,
                               rekeningen=rekeningen,
                               beleggingen=beleggingen)
    else:
        conn = sqlite3.connect('pythonsqlite.db')
        db = conn.cursor()
        if request.form.get("belegging") == "nieuw":
            db.execute(
                'UPDATE rekeningen SET balans=balans-? where rekeningnaam=? AND userid=?',
                (request.form.get("Bedrag"), request.form.get("rekening"),
                 session["user_id"]))
            db.execute(
                "INSERT INTO Beleggingen (userid, naam, prijs, waarde, portfolio, datum, verkocht) VALUES(?,?,?,?,?,date('now'), 0.0)",
                (session["user_id"], request.form.get("naam"),
                 request.form.get("Bedrag"), request.form.get("Waarde"),
                 request.form.get("portfolios")))
        else:
            db.execute(
                'UPDATE rekeningen SET balans=balans-? where rekeningnaam=? AND userid=?',
                (request.form.get("Bedrag"), request.form.get("rekening"),
                 session["user_id"]))
            db.execute(
                'UPDATE Beleggingen SET prijs=prijs+? where naam=? AND userid=?',
                (request.form.get("Bedrag"), request.form.get("belegging"),
                 session["user_id"]))
            db.execute(
                'UPDATE Beleggingen SET waarde=waarde+? where naam=? AND userid=?',
                (request.form.get("Waarde"), request.form.get("belegging"),
                 session["user_id"]))
        # commit changes
        conn.commit()
        return redirect("/beleggingen")
예제 #7
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def overschrijving():
    if request.method == "GET":
        db = db_connect('pythonsqlite.db')
        rows = db.execute("SELECT * FROM rekeningen WHERE userid = ? ",
                          (session["user_id"], ))
        rekeningen = rows.fetchall()
        return render_template("overschrijving.html", rekeningen=rekeningen)
    else:
        conn = sqlite3.connect('pythonsqlite.db')
        db = conn.cursor()
        db.execute(
            'UPDATE rekeningen SET balans=balans+? where rekeningnaam=? AND userid=?',
            (request.form.get("Hoeveelheid"), request.form.get("naar"),
             session["user_id"]))
        conn.commit()
        db.execute(
            'UPDATE rekeningen SET balans=balans-? where rekeningnaam=? AND userid=?',
            (request.form.get("Hoeveelheid"), request.form.get("van"),
             session["user_id"]))
        conn.commit()
        return redirect("/balans")
예제 #8
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def login():
    db = db_connect('pythonsqlite.db')
    if request.method == "GET":
        return render_template("login.html")
    elif request.method == "POST":
        # check for complete form better in JS
        if not request.form.get("username") or not request.form.get(
                "password"):
            return render_template("retry.html")
        rows = db.execute("SELECT * FROM users WHERE username = ?",
                          (request.form.get("username"), ))
        # Ensure username exists and password is correct
        row = rows.fetchone()
        if not row or not check_password_hash(row[2],
                                              request.form.get("password")):
            return render_template("retry.html")

        # Remember which user has logged in
        session["user_id"] = row[0]

        # Redirect user to home page
        return redirect("/")
예제 #9
0
    else:
        return float(val)


if __name__ == '__main__':
    opt_parser = optparse.OptionParser()
    opt_parser.add_option('-i',
                          '--input',
                          dest='input',
                          type='str',
                          action='store',
                          default=None,
                          help='Input CSV file')
    options, args = opt_parser.parse_args()

    conn = helpers.db_connect()
    cur = conn.cursor()

    cur.execute("DROP TABLE IF EXISTS school CASCADE")
    cur.execute('''
	CREATE TABLE school (
		id SERIAL PRIMARY KEY,
		leaid VARCHAR(255),
		schid VARCHAR(255),
		combokey VARCHAR(255),
		name VARCHAR(255),
		latitude FLOAT,
		longitude FLOAT,
		state CHAR(2),
		county_name VARCHAR(255),
		county_geoid VARCHAR(255),
예제 #10
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def beleggingen():
    if request.method == "GET":
        db = db_connect('pythonsqlite.db')
        rowsb = db.execute("SELECT * FROM Portfolios WHERE userid = ? ",
                           (session["user_id"], ))
        portfolios = rowsb.fetchall()
        # Neem alle beleggingen van huidige user voor op pagina te zetten
        rowsb = db.execute("SELECT * FROM Beleggingen WHERE Userid = ?",
                           (session["user_id"], ))
        beleggingen = rowsb.fetchall()
        # Bereken totaal van alle portfolios: prijs en waarde
        totaalbeleggingen = 0
        totaalprijs = 0
        totaalverkocht = 0
        for row in beleggingen:
            totaalprijs += row[2]
            totaalbeleggingen += row[3]
            totaalverkocht += row[6]
        # Bereken cash
        rowsb = db.execute("SELECT * FROM rekeningen WHERE userid = ? ",
                           (session["user_id"], ))
        rowb = rowsb.fetchall()
        cash = 0
        for row in rowb:
            cash += row[1]
        # Bereken 12 laatste maanden aan uitgaven
        selecteer = db.execute(
            "SELECT * FROM Transacties WHERE userid=? and Soort=? and Datum >= date('now','start of month', '-12 month') and Datum < date('now','start of month')",
            (session["user_id"], "Uitgave"))
        uitgaven = selecteer.fetchall()
        totaaluitgaven = 0
        for uitgave in uitgaven:
            totaaluitgaven += uitgave[2]
        return render_template("beleggingen.html",
                               portfolios=portfolios,
                               beleggingen=beleggingen,
                               totaalprijs=totaalprijs,
                               totaalbeleggingen=totaalbeleggingen,
                               cash=cash,
                               totaaluitgaven=totaaluitgaven,
                               totaalverkocht=totaalverkocht)
    else:
        conn = sqlite3.connect('pythonsqlite.db')
        db = conn.cursor()
        db.execute('UPDATE Beleggingen SET waarde=? where naam=? AND userid=?',
                   (request.form.get("update"), request.form.get("naam"),
                    session["user_id"]))
        # commit changes
        conn.commit()
        # voeg nieuwe status toe aan historiek
        # Neem alle beleggingen van huidige user voor op pagina te zetten
        rowsb = db.execute("SELECT * FROM Beleggingen WHERE Userid = ?",
                           (session["user_id"], ))
        beleggingen = rowsb.fetchall()
        # Bereken totaal van alle portfolios: prijs en waarde
        totaalbeleggingen = 0
        for row in beleggingen:
            totaalbeleggingen += row[3]
        # Bereken cash
        rowsb = db.execute("SELECT * FROM rekeningen WHERE userid = ? ",
                           (session["user_id"], ))
        rowb = rowsb.fetchall()
        cash = 0
        for row in rowb:
            cash += row[1]
        # Steek in historiek voor huidige datum
        db.execute(
            "INSERT INTO Historiek (userid, cash, beleggingen, datum) VALUES(?,?,?,date('now'))",
            (session["user_id"], cash, totaalbeleggingen))
        # commit changes
        conn.commit()
        return redirect("/beleggingen")
예제 #11
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def budget():
    if request.method == "GET":
        # Get data for Inkomsten
        db = db_connect('pythonsqlite.db')
        rowsb = db.execute("SELECT * FROM Inkomsten WHERE userid = ? ",
                           (session["user_id"], ))
        rowb = rowsb.fetchone()
        inkomst = rowb[1]
        # Get data for Status van inkomsten: enkel voor huidige maand
        rowsb = db.execute(
            "SELECT * FROM Transacties WHERE Userid = ? and Soort = ? and Datum >= date('now','start of month') and Datum < date('now','start of month','+1 month') ",
            (
                session["user_id"],
                "Inkomst",
            ))
        rowb = rowsb.fetchall()
        inkomhuidig = 0
        for row in rowb:
            inkomhuidig += row[2]
        # Neem alle budgetten van huidige user voor op pagina te zetten
        rowsb = db.execute("SELECT * FROM Budgetten WHERE Userid = ?",
                           (session["user_id"], ))
        budgetten = rowsb.fetchall()
        # Bereken totaal van alle budgetten
        totaalbudget = 0
        for row in budgetten:
            totaalbudget += row[2]
        # Selecteer alle budgetten en selecteer voor elke categorie erin alle transacties van huidige maand
        # en voeg toe aan totaal van dat budget
        db = db_connect('pythonsqlite.db')
        rowsb = db.execute("SELECT * FROM Budgetten WHERE userid = ? ",
                           (session["user_id"], ))
        rowb = rowsb.fetchall()
        # for loop met budgetten: voor elk budget: iterate over alle categorieën en select transacties als nt NULL
        budgethuidigen = []
        i = 0
        for budget in rowb:
            budgethuidigen.append(0)
            for categorie in range(32):
                if budget[categorie + 3] is not "NULL":
                    select = db.execute(
                        "SELECT * FROM Transacties WHERE userid=? and Subcategorie=? and Datum >= date('now','start of month') and Datum < date('now','start of month','+1 month')",
                        (session["user_id"], budget[categorie + 3]))
                    transacties = select.fetchall()
                    for transactie in transacties:
                        budgethuidigen[i] += transactie[2]
            i = i + 1
        totaalhuidigbudget = sum(budgethuidigen)
        # bereken totaal van uitgaven in huidige maand
        selecteer = db.execute(
            "SELECT * FROM Transacties WHERE userid=? and Soort=? and Datum >= date('now','start of month') and Datum < date('now','start of month','+1 month')",
            (session["user_id"], "Uitgave"))
        uitgaven = selecteer.fetchall()
        totaaluitgaven = 0
        for uitgave in uitgaven:
            totaaluitgaven += uitgave[2]
        # bereken totaal van inkomsten in huidige maand
        selecteer = db.execute(
            "SELECT * FROM Transacties WHERE userid=? and Soort=? and Datum >= date('now','start of month') and Datum < date('now','start of month','+1 month')",
            (session["user_id"], "Inkomst"))
        inkomsten = selecteer.fetchall()
        totaalinkomsten = 0
        for inkomst in inkomsten:
            totaalinkomsten += inkomst[2]
        return render_template("budget.html",
                               inkomsten=inkomst,
                               inkomhuidig=inkomhuidig,
                               budgetten=budgetten,
                               totaalbudget=totaalbudget,
                               budgethuidigen=budgethuidigen,
                               totaalhuidigbudget=totaalhuidigbudget,
                               totaaluitgaven=totaaluitgaven,
                               totaalinkomsten=totaalinkomsten)
    else:
        conn = sqlite3.connect('pythonsqlite.db')
        db = conn.cursor()
        # Delete last income
        db.execute("DELETE FROM Inkomsten WHERE userid=?",
                   (session["user_id"], ))
        conn.commit()
        # Insert transactie into database
        db.execute("INSERT INTO Inkomsten (userid, inkomsten) VALUES(?,?)",
                   (session["user_id"], request.form.get("inkomsten")))
        # commit changes
        conn.commit()
        return redirect("/budget")
예제 #12
0
파일: app.py 프로젝트: BetseBrothers/FinPro
def home():
    # Bereken cash
    db = db_connect('pythonsqlite.db')
    rowsb = db.execute("SELECT * FROM rekeningen WHERE userid = ? ",
                       (session["user_id"], ))
    rowb = rowsb.fetchall()
    balans = 0
    for row in rowb:
        balans += row[1]
    # Bereken beleggingen TODO
    # Bereken totaalbudget
    rowsb = db.execute("SELECT * FROM Budgetten WHERE Userid = ?",
                       (session["user_id"], ))
    budgetten = rowsb.fetchall()
    # Bereken totaal van alle budgetten
    totaalbudget = 0
    for row in budgetten:
        totaalbudget += row[2]
    # Bereken totaaluitgaven huidige maand
    selecteer = db.execute(
        "SELECT * FROM Transacties WHERE userid=? and Soort=? and Datum >= date('now','start of month') and Datum < date('now','start of month','+1 month')",
        (session["user_id"], "Uitgave"))
    uitgaven = selecteer.fetchall()
    totaaluitgaven = 0
    for uitgave in uitgaven:
        totaaluitgaven += uitgave[2]
    # bereken totaal van inkomsten in huidige maand
    selecteer = db.execute(
        "SELECT * FROM Transacties WHERE userid=? and Soort=? and Datum >= date('now','start of month') and Datum < date('now','start of month','+1 month')",
        (session["user_id"], "Inkomst"))
    inkomsten = selecteer.fetchall()
    totaalinkomsten = 0
    for inkomst in inkomsten:
        totaalinkomsten += inkomst[2]
    # Inkomsten
    rowsb = db.execute("SELECT * FROM Inkomsten WHERE userid = ? ",
                       (session["user_id"], ))
    rowb = rowsb.fetchone()
    inkomst = rowb[1]
    # Inkomstenhuidig
    # Savings
    # Savingshuidig
    # maand
    dbm = db_connect('pythonsqlite.db')
    rowsm = dbm.execute(
        "SELECT * FROM transacties WHERE userid=? AND Datum >= date('now','start of month') AND Datum < date('now','start of month','+1 month')",
        (session["user_id"], ))
    rowm = rowsm.fetchall()
    maandI = 0
    maandU = 0
    for row in rowm:
        if row[5] == "Inkomst":
            maandI += row[2]
        else:
            maandU += row[2]
    # jaar
    dbj = db_connect('pythonsqlite.db')
    rowsj = dbj.execute(
        "SELECT * FROM transacties WHERE userid=? AND Datum >= date('now','start of month') AND Datum < date('now','start of month','+1 month')",
        (session["user_id"], ))
    rowj = rowsj.fetchall()
    jaarI = 0
    jaarU = 0
    for row in rowj:
        if row[5] == "Inkomst":
            jaarI += row[2]
        else:
            jaarU += row[2]
    # Neem alle beleggingen van huidige user voor op pagina te zetten
    rowsb = db.execute("SELECT * FROM Beleggingen WHERE Userid = ?",
                       (session["user_id"], ))
    beleggingen = rowsb.fetchall()
    # Bereken totaal van alle portfolios: prijs en waarde
    totaalbeleggingen = 0
    totaalprijs = 0
    totaalverkocht = 0
    for row in beleggingen:
        totaalprijs += row[2]
        totaalbeleggingen += row[3]
        totaalverkocht += row[6]
    # Bereken 12 laatste maanden aan uitgaven
    selecteer = db.execute(
        "SELECT * FROM Transacties WHERE userid=? and Soort=? and Datum >= date('now','start of month', '-12 month') and Datum < date('now','start of month')",
        (session["user_id"], "Uitgave"))
    uitgaven = selecteer.fetchall()
    jaaruitgaven = 0
    for uitgave in uitgaven:
        jaaruitgaven += uitgave[2]
    return render_template("home.html",
                           jaaruitgaven=jaaruitgaven,
                           totaalprijs=totaalprijs,
                           totaalbeleggingen=totaalbeleggingen,
                           totaalverkocht=totaalverkocht,
                           balans=balans,
                           totaalbudget=totaalbudget,
                           totaaluitgaven=totaaluitgaven,
                           totaalinkomsten=totaalinkomsten,
                           inkomst=inkomst,
                           maandI=maandI,
                           maandU=maandU,
                           jaarI=jaarI,
                           jaarU=jaarU,
                           date=time.strftime("%x"),
                           month=time.strftime("%b"))
예제 #13
0
def data():
    """Do data magic."""
    if request.method == "POST":

        # Check for test link click
        if request.form.get("test") == "yes":
            email = config["TEST_ACCT"]
            units = "feet"
        # Otherwise, import values normally
        else:
            email = request.form.get("email")
            units = request.form.get("units")

        # Input validation - Thanks to emailregex.com for the regex
        regex = r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
        if not re.match(regex, email):
            e = "Please enter a valid email."
            return render_template("error.html", data=e)

        # Get user and id from MP
        userid = get_userid(email)
        # Check for a successful return from MP
        if userid["status"] == 1:
            e = (f"Connection error. MP Reply: {userid['code']}." +
                 " Please make sure you supplied a valid API key.")
            return render_template("error.html", data=e)
        elif userid["status"] == 2:
            e = "There is no user connected to that email. Please try again."
            return render_template("error.html", data=e)

        # Get ticklist from MP via CSV
        csv = ticklist(userid["name"], userid["id"])
        # Check for successful data return
        if csv["status"] == 1:
            e = (f"Error retriving ticklist. MP Reply: {csv['code']}." +
                 " Please try again later.")
            return render_template("error.html", data=e)

        # Check for dev mode
        if config["MPV_DEV"] != "on":
            # Put user's ticklist into the database
            database = db_load(userid['id'], csv['data'])
            # Check for database success
            if database['status'] == 1:
                e = f"Database error: {database['error']}"
                return render_template('error.html', data=e)

        # Connect to database for graph and stats generation
        connection = db_connect()
        cursor = connection.cursor()

        # Generate the stats and draw graph
        height = height_climbed(cursor, userid['id'], units)
        pitches = pitches_climbed(cursor, userid['id'])

        grade_scatters = list()
        for type in get_types(cursor, userid['id']):
            reply = grade_scatter(cursor, userid['id'], type)
            # Check for empty returns
            if reply:
                grade_scatters.append(reply)

        # Close the connection to the database
        db_close(cursor, connection)

        # Show final output
        return render_template("data.html",
                               username=userid['name'],
                               total_height=height['total'],
                               units=units,
                               height=height['plot'],
                               total_pitches=pitches['total'],
                               pitches=pitches['plot'],
                               scatters=grade_scatters)

    # Send them back to the index if they try to GET
    else:
        return redirect("/")