def create_db():
    conn = open_db.open_db()
    cursor = conn.cursor()
    create_tables(cursor)
    conn.commit()
    conn.close()
    gen_db.gen()
def main():

    c1,conn1 = open_db(sys.argv[1])
    c2,conn2 = open_db(sys.argv[2])

    for row in c2.execute('select * from teams'):
        print 'Extracting row'
        print 'Injecting row'
        c1.execute('insert into teams values (?,?,?,?,?,?,?,?,?)', row)

    print 'done'

    print 'saving...'
    conn1.commit()
    print 'closing...'
    conn1.close()
    conn2.close()
def main():
        c,conn = open_db()

        autoAverage(c)

        for row in c.execute('select * from auto group by team order by average desc'):
            print row

        raw_input('Press any key to continue...')
        return
Example #4
0
def main_cmd():
	c, conn = open_db()
	team = int(raw_input('Enter a Team: '))
	
	for row in c.execute('SELECT * FROM teams'):
		if row[0] == team:
		    print row
	
	raw_input('Press any key to continue...')
	return
Example #5
0
def main():
        c,conn = open_db()

        rankTeams(c)

        for x in c.execute('select * from rank order by score desc'):
                print x

        raw_input('Press any key to continue...')
        return
def main():
    c = open_db()
    match = int(raw_input('Enter a Match: '))

    data = queryMatch(match,c)

    for d in data:
        print d

    raw_input('Press any key to continue...')
    return
def main():
    c,conn = open_db()
    q = raw_input('Enter a stat to query: ')

    teams, stats = queryStat(q,c)

    for i, v in enumerate(teams):
        print v, stats[i]

    raw_input('Press enter to continue...')
    return
Example #8
0
def genOPR():
    
    c, conn = open_db()
    
    count = 0
    rowMax = 0
    teams = []
    colour = 0

    # team count
    for row in c.execute('select team from teams group by team'):
        count += 1
    teamCount = count
    # match count
    for row in c.execute('select match from teams order by match desc'):
        matchCount = row[0]
        break
    # team index
    for row in c.execute('select team from teams group by team order by team'):
        teams.append(row[0])

    # participation matrix
    P = np.zeros((matchCount*2,teamCount),np.float)
    for row in c.execute('select team,match,colour from teams order by match'):
        i = teams.index(row[0])
        if row[2] == 1:
            P[((row[1]-1)*2)+1][i] = 1
        else:
            P[(row[1]-1)*2][i] = 1
    
    #np.savetxt("pMat.csv", P, delimiter=',')

    #score vector
    S = np.zeros((matchCount*2,1),np.float)
    counter = 0
    for row in c.execute('select * from teams order by match'):
        if row[9] == 1:
            S[((row[1]-1)*2)+1] += (row[2]*6 + (row[3]*4) + (row[4]*2) + (row[5]*5) + row[6]*3 + row[7]*2 + row[8] + row[9])
        else:
            S[(row[1]-1)*2] += (row[2]*6 + (row[3]*4) + (row[4]*2) + (row[5]*5) + row[6]*3 + row[7]*2 + row[8] + row[9])

    # OPR calc
    opr = np.linalg.lstsq(P ,S)

    teamOPR = []
    for i, v in enumerate(teams):
        teamOPR.append([v,float(opr[0][i])])

    teamOPR.sort(key=lambda tup: tup[1], reverse=True)


    return teamOPR    
Example #9
0
def gen():
    conn = open_db()
    cursor = conn.cursor()

    nbook = gen_books(cursor)
    nconfig = gen_configs(cursor)
    nconc = gen_con_books(cursor, nbook, nconfig)
    nuser = gen_clients(cursor)
    nath = gen_authors(cursor)
    gen_author_book(cursor, nath, nbook)
    gen_incidents(cursor, nuser, nconc)
    gen_operations(cursor, nuser, nconc)
    gen_students(cursor, nuser)
    nprog = gen_program(cursor)
    nsubj = gen_subjects(cursor)
    gen_program_subject(cursor, nprog, nsubj)
    gen_book_subject(cursor, nbook, nsubj)

    conn.commit()
def main():
    c,conn = open_db()

    if(len(sys.argv) == 1):
        p1 = int(raw_input('Enter participant red 1: '))
        p2 = int(raw_input('Enter participant red 2: '))
        p3 = int(raw_input('Enter participant red 3: '))
        p4 = int(raw_input('Enter participant blue 1: '))
        p5 = int(raw_input('Enter participant blue 2: '))
        p6 = int(raw_input('Enter participant blue 3: '))

        redscore, bluscore = predictMatch(c,p1,p2,p3,p4,p5,p6)

        print 'Predicted result = red: ',redscore, '   Blue: ', bluscore

        raw_input('Press any key to continue...')
        return

    elif (len(sys.argv) == 3):
        schedule_csv = sys.argv[1]
        frc_ranks_csv = sys.argv[2]

        # copy past of the remaining matches from the schedule, no title row
        # get from frclinks
        schedule = np.loadtxt(schedule_csv, dtype=int, delimiter=',', usecols=[2,3,4,5,6,7])
        #print schedule

        # copy and past of the team ranks from frc links only first 5 columns used
        ranks = np.loadtxt(frc_ranks_csv, dtype=int, delimiter=',', skiprows=1, usecols=[1,2,3,4,5])
        #print ranks

        for row in schedule:
            redScore, blueScore = predictMatch(c,row[0],row[1],row[2],row[3],row[4],row[5])

            if(redScore > blueScore):
                print 'Match: ', row, ' red wins', int(redScore), 'to', int(blueScore)
                idx = np.where(ranks==row[0])[0]
                ranks[idx,1] += 2

                idx = np.where(ranks==row[1])[0]
                ranks[idx,1] += 2

                idx = np.where(ranks==row[2])[0]
                ranks[idx,1] += 2

            if(blueScore > redScore):
                print 'Match: ', row, ' blue wins', int(blueScore), 'to', int(redScore)
                idx = np.where(ranks==row[3])[0]
                ranks[idx,1] += 2

                idx = np.where(ranks==row[4])[0]
                ranks[idx,1] += 2

                idx = np.where(ranks==row[5])[0]
                ranks[idx,1] += 2

        #print ranks
        ranks = ranks[np.lexsort((ranks[:,0], ranks[:,1]))]
        ranks = np.flipud(ranks)
        #print ranks
        np.savetxt('data/newRanks.csv', ranks, fmt='%d', delimiter=',')

        raw_input('Press Enter to Continue...')
        return
import sqlite3
from open_db import open_db

c, conn = open_db()

c.execute('DROP TABLE IF EXISTS pitScouting')
conn.commit
conn.close
def main():

    q = 0
    
    c,conn = open_db()

    while q != '':
        q = raw_input('Enter a Team to query: ')
		
    top = Tk()

    top.title("Compare Teams")
    top.resizable(1, 1)
    top.maxsize(4000, 4000)

    

    ExtraRow = Label(top, text="    ")
    ExtraRow.grid(row=10, column=0)

    Column1 = Label(top, text="Match") 
    Column1.grid(row=1, column=0)

    Column2 = Label(top, text="Auto Three") 
    Column2.grid(row=1, column=1)

    Column3 = Label(top, text="Auto Two") 
    Column3.grid(row=1, column=2)

    Column4 = Label(top, text="Auto One") 
    Column4.grid(row=1, column=3)

    Column5 = Label(top, text="Five") 
    Column5.grid(row=1, column=4)

    Column6 = Label(top, text="Three") 
    Column6.grid(row=1, column=5)

    Column7 = Label(top, text="Two") 
    Column7.grid(row=1, column=6)

    Column8 = Label(top, text="one") 
    Column8.grid(row=1, column=7)

    Column9= Label(top, text="climb") 
    Column9.grid(row=1, column=8)

    Column10 = Label(top, text="notes") 
    Column10.grid(row=1, column=9)

    Column11 = Label(top, text="Match") 
    Column11.grid(row=1, column=11)

    Column12 = Label(top, text="Auto Three") 
    Column12.grid(row=1, column=12)

    Column13 = Label(top, text="Auto Two") 
    Column13.grid(row=1, column=13)

    Column14 = Label(top, text="Auto One") 
    Column14.grid(row=1, column=14)

    Column15 = Label(top, text="Five") 
    Column15.grid(row=1, column=15)

    Column16 = Label(top, text="Three") 
    Column16.grid(row=1, column=16)

    Column17 = Label(top, text="Two") 
    Column17.grid(row=1, column=17)

    Column18 = Label(top, text="one") 
    Column18.grid(row=1, column=18)

    Column19 = Label(top, text="climb") 
    Column19.grid(row=1, column=19)

    Column20 = Label(top, text="notes") 
    Column20.grid(row=1, column=20)

    Column21 = Label(top, text="Match") 
    Column21.grid(row=1, column=22)

    Column22 = Label(top, text="Auto Three") 
    Column22.grid(row=1, column=23)

    Column23 = Label(top, text="Auto Two") 
    Column23.grid(row=1, column=24)

    Column24 = Label(top, text="Auto One") 
    Column24.grid(row=1, column=25)

    Column25 = Label(top, text="Five") 
    Column25.grid(row=1, column=26)

    Column26 = Label(top, text="Three") 
    Column26.grid(row=1, column=27)

    Column27 = Label(top, text="Two") 
    Column27.grid(row=1, column=28)

    Column28 = Label(top, text="one") 
    Column28.grid(row=1, column=29)

    Column29= Label(top, text="climb") 
    Column29.grid(row=1, column=30)

    Column30 = Label(top, text="notes") 
    Column30.grid(row=1, column=31)

    Column31 = Label(top, text="Match") 
    Column31.grid(row=12, column=0)

    Column32 = Label(top, text="Auto Three") 
    Column32.grid(row=12, column=1)

    Column33 = Label(top, text="Auto Two") 
    Column33.grid(row=12, column=2)

    Column34 = Label(top, text="Auto One") 
    Column34.grid(row=12, column=3)

    Column35 = Label(top, text="Five") 
    Column35.grid(row=12, column=4)

    Column36 = Label(top, text="Three") 
    Column36.grid(row=12, column=5)

    Column37 = Label(top, text="Two") 
    Column37.grid(row=12, column=6)

    Column38 = Label(top, text="one") 
    Column38.grid(row=12, column=7)

    Column39 = Label(top, text="climb") 
    Column39.grid(row=12, column=8)

    Column40 = Label(top, text="notes") 
    Column40.grid(row=12, column=9)

    Column41 = Label(top, text="Match") 
    Column41.grid(row=12, column=22)

    Column42 = Label(top, text="Auto Three") 
    Column42.grid(row=12, column=23)

    Column43 = Label(top, text="Auto Two") 
    Column43.grid(row=12, column=24)

    Column44 = Label(top, text="Auto One") 
    Column44.grid(row=12, column=25)

    Column45 = Label(top, text="Five") 
    Column45.grid(row=12, column=26)

    Column46 = Label(top, text="Three") 
    Column46.grid(row=12, column=27)

    Column47 = Label(top, text="Two") 
    Column47.grid(row=12, column=28)

    Column48 = Label(top, text="one") 
    Column48.grid(row=12, column=29)

    Column49 = Label(top, text="climb") 
    Column49.grid(row=12, column=30)

    Column50 = Label(top, text="notes") 
    Column50.grid(row=12, column=31)

    #team1 = Label(top, text=Team1)
    #team1.grid(row=2, column=0)

    count = 0

    for row in c.execute('SELECT * FROM teams'):
        if count == 0:
            if row[0] == q:

                Team1Lbl = Label(top, text=q)
                Team1Lbl.grid(row=0, column=3)
                
                Team2Lbl = Label(top, text=q)
                Team2Lbl.grid(row=0, column=14)
                
                match1 = Label(top, text=row[1])
                match1.grid(row=count, column=0)

                autoThree1 = Label(top, text=row[2])
                autoThree1.grid(row=count, column=1)

                autoTwo1 = Label(top, text=row[3])
                autoTwo1.grid(row=count, column=2)

                autoOne1 = Label(top, text=row[4])
                autoOne1.grid(row=count, column=3)

                
                five1 = Label(top, text=row[5])
                five1.grid(row=count, column=4)

                three1 = Label(top, text=row[6])
                three1.grid(row=count, column=5)

                two1 = Label(top, text=row[7])
                two1.grid(row=count, column=6)

                one1 = Label(top, text=row[8])
                one1.grid(row=count, column=7)

                climb1 = Label(top, text=row[9])
                climb1.grid(row=count, column=8)
                
                count = 1

    space = Label(top, text="       ")
    space.grid(row=2, column=10)

    space2 = Label(top, text="       ")
    space2.grid(row=2, column=21)

    space3 = Label(top, text="       ")
    space3.grid(row=2, column=32)

    space4 = Label(top, text="       ")
    space4.grid(row=2, column=43)


    '''    

        Team3Lbl = Label(top, text=team3)
        Team3Lbl.grid(row=0, column=25)

        Team4Lbl = Label(top, text=team4)
        Team4Lbl.grid(row=11, column=3)

        Team5Lbl = Label(top, text=team5)
        Team5Lbl.grid(row=11, column=25)
    '''
        
                      
    for row in c.execute('select * from teams'):
        if count == 1:
            if row[0] == q:
                match2 = Label(top, text=row[1])
                match2.grid(row=count, column=11)

                autoThree2 = Label(top, text=row[2])
                autoThree2.grid(row=count, column=12)

                autoTwo2 = Label(top, text=row[3])
                autoTwo2.grid(row=count, column=13)

                autoOne2 = Label(top, text=row[4])
                autoOne2.grid(row=count, column=14)

                five2 = Label(top, text=row[5])
                five2.grid(row=count, column=15)

                three2 = Label(top, text=row[6])
                three2.grid(row=count, column=16)

                two2 = Label(top, text=row[7])
                two2.grid(row=count, column=17)

                one2 = Label(top, text=row[8])
                one2.grid(row=count, column=18)

                climb2 = Label(top, text=row[9])
                climb2.grid(row=count, column=19)

                count = 2

    for row in c.execute('select * from teams'):
        if count == 2:
            if row[0] == q:
                match3 = Label(top, text=row[1])
                match3.grid(row=count, column=22)

                autoThree3 = Label(top, text=row[2])
                autoThree3.grid(row=count, column=23)

                autoTwo3 = Label(top, text=row[3])
                autoTwo3.grid(row=count, column=24)

                autoOne3 = Label(top, text=row[4])
                autoOne3.grid(row=count, column=25)

                five3 = Label(top, text=row[5])
                five3.grid(row=count, column=26)

                three3 = Label(top, text=row[6])
                three3.grid(row=count, column=27)

                two3 = Label(top, text=row[7])
                two3.grid(row=count, column=28)

                one3 = Label(top, text=row[8])
                one3.grid(row=count, column=29)

                climb3 = Label(top, text=row[9])
                climb3.grid(row=count, column=30)

                count = 3

    for row in c.execute('select * from teams'):
        if count == 3:
            if row[0] == q:
                match4 = Label(top, text=row[1])
                match4.grid(row=count, column=0)

                autoThree4 = Label(top, text=row[2])
                autoThree4.grid(row=count, column=1)

                autoTwo4 = Label(top, text=row[3])
                autoTwo4.grid(row=count, column=2)

                autoOne4 = Label(top, text=row[4])
                autoOne4.grid(row=count, column=3)

                five4 = Label(top, text=row[5])
                five4.grid(row=count, column=4)

                three4 = Label(top, text=row[6])
                three4.grid(row=count, column=5)

                two4 = Label(top, text=row[7])
                two4.grid(row=count, column=6)

                one4 = Label(top, text=row[8])
                one4.grid(row=count, column=7)

                climb4 = Label(top, text=row[9])
                climb4.grid(row=count, column=8)

                count = 4

    for row in c.execute('select * from teams'):
        if count == 4:
            if row[0] == q:
                match5 = Label(top, text=row[1])
                match5.grid(row=count, column=22)

                autoThree5 = Label(top, text=row[2])
                autoThree5.grid(row=count, column=23)

                autoTwo5 = Label(top, text=row[3])
                autoTwo5.grid(row=count, column=24)

                autoOne5 = Label(top, text=row[4])
                autoOne5.grid(row=count, column=25)

                five5 = Label(top, text=row[5])
                five5.grid(row=count, column=26)

                three5 = Label(top, text=row[6])
                three5.grid(row=count, column=27)

                two5 = Label(top, text=row[7])
                two5.grid(row=count, column=28)

                one5 = Label(top, text=row[8])
                one5.grid(row=count, column=29)

                climb5 = Label(top, text=row[9])
                climb5.grid(row=count, column=30)

    top.focus_set()
    top.mainloop()
Example #13
0
def main():
    c, conn = open_db()
    team = int(raw_input('Enter a Team: '))
    
    top = Tk()

    top.title("queryTeam")
    top.resizable(1, 1)
    top.maxsize(2000, 2000)

    Team1Lbl = Label(top, text=team)
    Team1Lbl.grid(row=0, column=3, sticky=N+E+W+S)

    Column1 = Label(top, text="Match") 
    Column1.grid(row=1, column=0, sticky=N+E+W+S)
    
    Column2 = Label(top, text="AutoThree") 
    Column2.grid(row=1, column=1, sticky=N+E+W+S)
    
    Column2 = Label(top, text="AutoTwo") 
    Column2.grid(row=1, column=2, sticky=N+E+W+S)
    
    Column2 = Label(top, text="AutoOne") 
    Column2.grid(row=1, column=3, sticky=N+E+W+S)

    Column3 = Label(top, text="Five") 
    Column3.grid(row=1, column=4, sticky=N+E+W+S)

    Column4 = Label(top, text="Three") 
    Column4.grid(row=1, column=5, sticky=N+E+W+S)

    Column5 = Label(top, text="Two") 
    Column5.grid(row=1, column=6, sticky=N+E+W+S)

    Column6 = Label(top, text="one") 
    Column6.grid(row=1, column=7, sticky=N+E+W+S)

    Column7= Label(top, text="climb") 
    Column7.grid(row=1, column=8, sticky=N+E+W+S)

    Column8 = Label(top, text="notes") 
    Column8.grid(row=1, column=9, sticky=N+E+W+S)

    count = 1

    for row in c.execute('select * from teams'):
        if row[0] == team:
            count += 1
            match1 = Label(top, text=row[1])
            match1.grid(row=count, column=0, sticky=N+E+W+S)

            autoThree1 = Label(top, text=row[2])
            autoThree1.grid(row=count, column=1, sticky=N+E+W+S)

            autoTwo1 = Label(top, text=row[3])
            autoTwo1.grid(row=count, column=2, sticky=N+E+W+S)

            autoOne1 = Label(top, text=row[4])
            autoOne1.grid(row=count, column=3, sticky=N+E+W+S)

            five1 = Label(top, text=row[5])
            five1.grid(row=count, column=4, sticky=N+E+W+S)

            three1 = Label(top, text=row[6])
            three1.grid(row=count, column=5, sticky=N+E+W+S)

            two1 = Label(top, text=row[7])
            two1.grid(row=count, column=6, sticky=N+E+W+S)

            one1 = Label(top, text=row[8])
            one1.grid(row=count, column=7, sticky=N+E+W+S)

            climb1 = Label(top, text=row[9])
            climb1.grid(row=count, column=8, sticky=N+E+W+S)

    top.focus_set()
    top.mainloop()
def main():

    c,conn = open_db()

    while True:
        cmd = raw_input('Enter a Command: ')

        if cmd == 'input':
            line = 1
            expectedScore = 0
            match = int(raw_input('match: '))
            while line < 7:
                try:
                    team = int(raw_input('Team: '))

                    colour = int(raw_input('Alliance Color: (0 for Red 1 For Blue)'))
                    autoThree = int(raw_input('Autonomous Three Pointers: '))
                    autoTwo = int(raw_input('Autonomous Two Pointers: '))
                    autoOne = int(raw_input('Autonomous One Pointers: '))
                    three = int(raw_input('Three pointers: '))
                    two = int(raw_input('Two pointers: '))
                    one = int(raw_input('One Pointers: '))
                    five = int(raw_input('Five Pointers: '))
                    climb = int(raw_input('climb score: '))
                    while climb != 10 and climb != 20 and climb != 30 and climb != 0:
                        print 'Invalid Input, climb score can only be 0, 10, 20 or 30'
                        climb = int(raw_input('climb score: '))
                    notes = str(raw_input('notes: '))
                    expectedScore = expectedScore + (autoThree*6) + (autoTwo*4) + (autoOne*2) + (five*5) + (three*3) + (two*2) + one + climb
                    if line == 3:
                        redScore = int(raw_input('Red Team total: '))
                        if expectedScore != redScore:
                            print 'User Error: Score inputs do not match!'
                        expectedScore = 0
                    if line == 6:
                        bluScore = int(raw_input('Blue Team Score: '))
                        if expectedScore != bluScore:
                            print 'User Error: Score inputs do not match'
                        expectedScore = 0
                    row = (team,match,autoThree,autoTwo,autoOne,five,three,two,one,climb,notes,colour)
                    c.execute('INSERT INTO teams VALUES (?,?,?,?,?,?,?,?,?,?,?,?)', row)
                    line += 1
                except ValueError:
                    print 'invalid number'

        elif cmd == 'output':
            for row in c.execute('SELECT * FROM teams ORDER BY team'):
                print row

        elif cmd == 'save':
            conn.commit()
            conn.close()
            main()
            break

        elif cmd == 'clear':
            c.execute('DROP TABLE if exists teams')
            c.execute('''CREATE TABLE teams
                        (team, match, autoThree, autoTwo, autoOne, five, three,
                        two, one, climb, notes, colour)''')

        else:
            print 'unrecognized command'

    return