-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
308 lines (275 loc) · 10.9 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
from flask import Flask,render_template,request, template_rendered
app=Flask(__name__,template_folder="template")
import pypyodbc
global connection
connection=''
@app.route("/")
def login():
return render_template("Login.html")
@app.route("/#page",methods=["GET","POST"])
def cred():
if request.method=="POST":
uid=request.form.get("uid")
pwd=request.form.get("pwd")
uid=str(uid)
pwd=str(pwd)
try:
connection=pypyodbc.connect('Driver={SQL Server};Server=LAPTOP-C1RC1D4R;UID='+uid+';pwd='+pwd+';DATABASE=IPL_DATABASE')
#print("Connected")
global cur
cur=connection.cursor()
print("Connected")
return render_template("AdminHome.html")
except:
print("Not able to connect")
return render_template("LoginPage.html")
return render_template("LoginPage.html")
@app.route("/adminhome")
def adminhome():
return render_template("AdminHome.html")
@app.route("/home")
def home():
try:
connection=pypyodbc.connect('Driver={SQL Server};Server=LAPTOP-C1RC1D4R;UID=sa1;pwd=12345;DATABASE=IPL_DATABASE')
#print("Connected")
global cur
cur=connection.cursor()
print("Connected")
return render_template("Home.html")
except:
print("Not able to connect")
@app.route("/query",methods=["GET","POST"])
def query():
data=""
if request.method=="POST":
query=request.form.get("query")
cur.execute(query)
data=cur.fetchall()
return render_template("query.html",data=data)
@app.route("/player")
def player():
return render_template("Player.html")
@app.route("/playerbyname",methods=["GET","POST"])
def PlayerName():
query="SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='Player'"
cur.execute(query)
column=cur.fetchall()
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Player where Name=\'"+name+"\'")
data=cur.fetchall()
print(data)
return render_template("PlayerByName.html",data=[column,data])
@app.route("/playercountry",methods=["GET","POST"])
def SelectPlayer():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Player where Nationality=\'"+name+"\'")
data=cur.fetchall()
return render_template("PlayerbyCountry.html",data=data)
@app.route("/playerteam",methods=["GET","POST"])
def SelectTeam():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Player where Team_Name=\'"+name+"\'")
data=cur.fetchall()
return render_template("PlayerbyTeamName.html",data=data)
@app.route("/batsman",methods=["GET","POST"])
def Batsman():
return render_template("Batsman.html")
@app.route("/batsmanID",methods=["GET","POST"])
def BatsmanID():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Batsman where Player_ID=\'"+name+"\'")
data=cur.fetchall()
return render_template("BatsmanID.html",data=data)
@app.route("/bowler",methods=["GET","POST"])
def Bowler():
return render_template("Bowler.html")
@app.route("/bowlerID",methods=["GET","POST"])
def BowlerID():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Bowler where Player_ID=\'"+name+"\'")
data=cur.fetchall()
return render_template("BowlerID.html",data=data)
@app.route("/coach")
def coach():
return render_template("Coach.html")
@app.route("/coachname",methods=["GET","POST"])
def CoachName():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Coach where Name=\'"+name+"\'")
data=cur.fetchall()
return render_template("CoachName.html",data=data)
@app.route("/coachrole",methods=["GET","POST"])
def CoachRole():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Coach where Role=\'"+name+"\'")
data=cur.fetchall()
return render_template("CoachRole.html",data=data)
@app.route("/coachteam",methods=["GET","POST"])
def CoachTeam():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Coach where Team_ID=\'"+name+"\'")
data=cur.fetchall()
return render_template("CoachTeam.html",data=data)
@app.route("/match")
def match():
return render_template("Match.html")
@app.route("/matchid", methods=["GET","POST"])
def matchID():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Match_ID=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchID.html",data=data)
@app.route("/matchlocation", methods=["GET","POST"])
def matchlocation():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Location=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchLocation.html",data=data)
@app.route("/matchstadiumid", methods=["GET","POST"])
def matchstadiumID():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Stadium_ID=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchStadiumID.html",data=data)
@app.route("/matchtossdecision", methods=["GET","POST"])
def matchtossdecision():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Toss_Decision=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchTossDecision.html",data=data)
@app.route("/matchtossoutcome", methods=["GET","POST"])
def matchtossoutcome():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Toss_Winner=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchTossOutcome.html",data=data)
@app.route("/matchtosswinner", methods=["GET","POST"])
def matchtosswinner():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Win_Team_ID=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchTossWinner.html",data=data)
@app.route("/matchwinteamid", methods=["GET","POST"])
def matchwinteamid():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Win_Team_ID=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchWinTeamID.html",data=data)
@app.route("/matchwinmethod", methods=["GET","POST"])
def matchwinmethod():
data=""
if request.method=="POST":
name=request.form.get("name")
cur.execute("select * from Match where Win_Method=\'"+name+"\'")
data=cur.fetchall()
return render_template("MatchWinMethod.html",data=data)
@app.route("/insertinto")
def insertinto():
return render_template("InsertReturn.html")
@app.route("/insertintoplayer", methods=["GET","POST"])
def insertintoplayer():
data=''
try:
if request.method=="POST":
playerid=request.form.get("playerid")
name=request.form.get("name")
dob=request.form.get("dob")
nationality=request.form.get("nationality")
teamname=request.form.get("teamname")
cur.execute("Insert into Player values(\'"+playerid+"\',\'"+name+"\',\'"+dob+"\',\'"+nationality+"\',\'"+teamname+"\');")
return render_template("Success.html")
except:
return render_template("Failure.html")
return render_template("InsertIntoPlayer.html",data=data)
@app.route("/insertintobatsman", methods=["GET","POST"])
def insertintobatsman():
data=''
try:
if request.method=="POST":
ballsplayed=request.form.get("ballsplayed")
scored=request.form.get("scored")
fours=request.form.get("fours")
sixes=request.form.get("sixes")
playerid=request.form.get("playerid")
cur.execute("Insert into Batsman values("+ballsplayed+","+scored+","+fours+","+sixes+",\'"+playerid+"\');")
return render_template("Success.html")
except:
return render_template("Failure.html")
return render_template("InsertIntoBatsman.html",data=data)
@app.route("/insertintobowler", methods=["GET","POST"])
def insertintobowler():
data=''
try:
if request.method=="POST":
runsgiven=request.form.get("runsgiven")
ballsbowled=request.form.get("ballsbowled")
wicketstaken=request.form.get("wicketstaken")
wides=request.form.get("wides")
dotballs=request.form.get("dotballs")
noballs=request.form.get("noballs")
playerid=request.form.get("playerid")
cur.execute("Insert into Bowler values("+runsgiven+","+ballsbowled+","+wicketstaken+","+wides+","+dotballs+","+noballs+",\'"+playerid+"\');")
return render_template("Success.html")
except:
return render_template("Failure.html")
return render_template("InsertIntoBowler.html",data=data)
# @app.route("/insertintoplayer", methods=["GET","POST"])
# def insertintobatsman():
# data=''
# try:
# if request.method=="POST":
# playerid=request.form.get("playerid")
# name=request.form.get("name")
# dob=request.form.get("dob")
# nationality=request.form.get("nationality")
# teamname=request.form.get("teamname")
# cur.execute("Insert into Player values(\'"+playerid+"\',\'"+name+"\',\'"+dob+"\',\'"+nationality+"\',\'"+teamname+"\');")
# return render_template("Success.html")
# except:
# return render_template("Failure.html")
# return render_template("insertIntoPlayer.html",data=data)
# @app.route("/insertintoplayer", methods=["GET","POST"])
# def insertintobatsman():
# data=''
# try:
# if request.method=="POST":
# playerid=request.form.get("playerid")
# name=request.form.get("name")
# dob=request.form.get("dob")
# nationality=request.form.get("nationality")
# teamname=request.form.get("teamname")
# cur.execute("Insert into Player values(\'"+playerid+"\',\'"+name+"\',\'"+dob+"\',\'"+nationality+"\',\'"+teamname+"\');")
# return render_template("Success.html")
# except:
# return render_template("Failure.html")
# return render_template("insertIntoPlayer.html",data=data)