Moving and naming SQL statements
This commit is contained in:
parent
ec7ff3e3e1
commit
4d04ce697f
@ -37,7 +37,7 @@ def convenorAddClubResult():
|
|||||||
_club = request.form['clubName']
|
_club = request.form['clubName']
|
||||||
club_lookup = "SELECT club FROM _clubTeams WHERE club='" + _club + "' GROUP BY club"
|
club_lookup = "SELECT club FROM _clubTeams WHERE club='" + _club + "' GROUP BY club"
|
||||||
club_create = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', 'A')"
|
club_create = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', 'A')"
|
||||||
|
|
||||||
# validate that this data has been entered
|
# validate that this data has been entered
|
||||||
if _club and request.method == 'POST':
|
if _club and request.method == 'POST':
|
||||||
clubExist = sql_read(club_lookup)
|
clubExist = sql_read(club_lookup)
|
||||||
@ -51,8 +51,8 @@ def convenorAddClubResult():
|
|||||||
|
|
||||||
@routes.route('/convenor/teamAdd')
|
@routes.route('/convenor/teamAdd')
|
||||||
def convenorAddTeam():
|
def convenorAddTeam():
|
||||||
sql = "SELECT club FROM _clubTeams GROUP BY club ORDER BY club"
|
clubs_query = "SELECT club FROM _clubTeams GROUP BY club ORDER BY club"
|
||||||
clubs = sql_read(sql)
|
clubs = sql_read(clubs_query)
|
||||||
form = addTeamForm()
|
form = addTeamForm()
|
||||||
return render_template('_convenorTeamAdd.html', data=clubs, form=form)
|
return render_template('_convenorTeamAdd.html', data=clubs, form=form)
|
||||||
|
|
||||||
@ -61,14 +61,15 @@ def convenorAddTeamResult():
|
|||||||
try:
|
try:
|
||||||
_club = request.form['clubName']
|
_club = request.form['clubName']
|
||||||
_team = request.form['teamName']
|
_team = request.form['teamName']
|
||||||
|
clubTeam_lookup = "SELECT club, team FROM _clubTeams WHERE club='" + _club + "' AND team='" + _team + "'"
|
||||||
|
clubTeam_create = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', '" + _team + "')"
|
||||||
if _club and _team and request.method == 'POST':
|
if _club and _team and request.method == 'POST':
|
||||||
sql = "SELECT club, team FROM _clubTeams WHERE club='" + _club + "' AND team='" + _team + "'"
|
sql =
|
||||||
teamExist = sql_read(sql)
|
teamExist = sql_read(clubTeam_lookup)
|
||||||
if teamExist:
|
if teamExist:
|
||||||
return 'Team already exists in the database'
|
return 'Team already exists in the database'
|
||||||
else:
|
else:
|
||||||
sql2 = "INSERT INTO _clubTeams (club, team) VALUES ('" + _club + "', '" + _team + "')"
|
sql_write(clubTeam_create)
|
||||||
sql_write(sql2)
|
|
||||||
return render_template('_convenorTeamAddResults.html', club=_club, team=_team)
|
return render_template('_convenorTeamAddResults.html', club=_club, team=_team)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user