School House Points (Python + SQLite) I am creating a database to store house points for our school running events. I would like to be able to tally all the points for the houses and it is working fine, however, I think it may be a bit verbose at this point.

Is there a simpler/better way with maybe more efficient code?

Races are stored in a races table (competitorID, raceID, time).

Student data is stored in a competitor table (competitorID, names, house).

The code will query the DB and bring back unique races, and then assign a point value based on their position (calculated by their race time).

import sqlite3
conn = sqlite3.connect('house.db')
conn.row_factory = sqlite3.Row

# House Totals
blueTotal = 0
greenTotal = 0
redTotal = 0
yellowTotal = 0

# Assign points from 1st = 15 through to 10-Last being 1
def points():
    global pointvalue
    if count == 0:
        pointvalue = 15
        places()
    if count == 1:
        pointvalue = 12
        places()
    if count == 2:
        pointvalue = 10
        places()
    if count == 3:
        pointvalue = 8
        places()
    if count == 4:
        pointvalue = 7
        places()
    if count == 5:
        pointvalue = 6
        places()
    if count == 6:
        pointvalue = 5
        places()
    if count == 7:
        pointvalue = 4
        places()
    if count == 8:
        pointvalue = 3
        places()
    if count == 9:
        pointvalue = 2
        places()
    if count &gt; 10:
        pointvalue = 1
        places()

#Add points to houses
def places():
    global blueTotal, greenTotal, redTotal, yellowTotal, pointvalue
    if competitors['house'] == "blueTotal":
        blueTotal += pointvalue
    if competitors['house'] == "redTotal":
        redTotal += pointvalue
    if competitors['house'] == "yellowTotal":
        yellowTotal += pointvalue
    if competitors['house'] == "greenTotal":
        greenTotal += pointvalue

for x in range(1,50):
    competitorDetails = conn.execute('SELECT firstname, surname, house '
                                     'FROM race, competitor '
                                     'WHERE competitor.competitorID = race.competitorID '
                                     'AND race.raceID = ' + str(x))
    count=0
    for competitors in competitorDetails:
        points()
        count += 1


print("blueTotal " + str(blueTotal))
print("greenTotal " + str(greenTotal))
print("redTotal " + str(redTotal))
print("yellowTotal " + str(yellowTotal))
DRY
This repetitive code is an anti-pattern:
blueTotal = 0
greenTotal = 0
redTotal = 0
yellowTotal = 0

Please define
houses = 'blue green red yellow'.split()

and then you can use array access to perform &quot;the same action&quot; across all houses:
for house in houses:
    total[house] = 0

One could also assign total = collections.defaultdict(int), but that would
be a horse of a different color.
(https://docs.python.org/3/library/collections.html#collections.defaultdict)
global
The global keyword is usually not your friend,
it leads to unfortunate coupling.
Here, it is offering you a hint that you want to define a class,
set totals to zero in the __init__() constructor,
and then have places() access self.total[].
arg passing
This is a bit crazy:
    for competitors in competitorDetails:
        points()

Yes, you can treat competitors as an implicit argument
by making it global, but there is absolutely no reason to,
and the current code makes it extremely difficult for readers
to understand what is going on. Please, please make competitors
an explicit argument, passing it in with points(competitors).
formatting
Clearly this works:
print(&quot;blueTotal &quot; + str(blueTotal))

but the explicit call to str is slightly verbose.
Consider re-phrasing such print statements in one of these ways:
print(&quot;blueTotal&quot;, blueTotal)
print(f'blueTotal {blueTotal}')