Start changing model to kaggle database
This commit is contained in:
16
formula10.py
16
formula10.py
@ -30,11 +30,19 @@ def default_statistic(year):
|
|||||||
|
|
||||||
@app.route("/seasons/<year>/<statistic>/")
|
@app.route("/seasons/<year>/<statistic>/")
|
||||||
def seasons(year, statistic):
|
def seasons(year, statistic):
|
||||||
seasons = Season.query.all()
|
seasons = db.session.execute(db.select(Season)).all() # For season selector
|
||||||
|
|
||||||
return render_template(
|
# @todo
|
||||||
"season.jinja", year=year, statistic=statistic, seasons=seasons
|
races = db.session.execute(db.select(Race).where(Race.year==year)).all()
|
||||||
)
|
print(races[0].raceId)
|
||||||
|
|
||||||
|
# results = dict()
|
||||||
|
# for race in races:
|
||||||
|
# results[race.raceId] = db.session.execute(db.select(Result).filter_by(raceId=race.raceId)).all()
|
||||||
|
|
||||||
|
# return render_template(
|
||||||
|
# "season.jinja", year=year, statistic=statistic, seasons=seasons, races=races, results=results
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
# @app.route("/teams", methods=["GET", "POST"])
|
# @app.route("/teams", methods=["GET", "POST"])
|
||||||
|
|||||||
16
model.py
16
model.py
@ -80,8 +80,8 @@ class Race(db.Model):
|
|||||||
self.round = int(row[2])
|
self.round = int(row[2])
|
||||||
self.circuitId = int(row[3])
|
self.circuitId = int(row[3])
|
||||||
self.name = str(row[4])
|
self.name = str(row[4])
|
||||||
self.date = optional_date(row[5]) # shouldn't return none here
|
self.date = str(row[5])
|
||||||
self.time = optional_time(row[6])
|
self.time = optional_str(row[6])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
raceId: Mapped[int] = mapped_column(Integer, primary_key=True)
|
raceId: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||||
@ -89,8 +89,8 @@ class Race(db.Model):
|
|||||||
round: Mapped[int] = mapped_column(Integer)
|
round: Mapped[int] = mapped_column(Integer)
|
||||||
circuitId: Mapped[int] = mapped_column(ForeignKey("circuit.circuitId"))
|
circuitId: Mapped[int] = mapped_column(ForeignKey("circuit.circuitId"))
|
||||||
name: Mapped[str] = mapped_column(String(128))
|
name: Mapped[str] = mapped_column(String(128))
|
||||||
date: Mapped[dt.date] = mapped_column(Date)
|
date: Mapped[str] = mapped_column(String(32))
|
||||||
time: Mapped[Optional[dt.time]] = mapped_column(Time)
|
time: Mapped[Optional[str]] = mapped_column(String(32))
|
||||||
|
|
||||||
circuit: Mapped["Circuit"] = relationship("Circuit", foreign_keys=[circuitId])
|
circuit: Mapped["Circuit"] = relationship("Circuit", foreign_keys=[circuitId])
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class Driver(db.Model):
|
|||||||
self.code = str(row[3])
|
self.code = str(row[3])
|
||||||
self.forename = str(row[4])
|
self.forename = str(row[4])
|
||||||
self.surname = str(row[5])
|
self.surname = str(row[5])
|
||||||
self.dob = optional_date(row[6]) # shouldn't return None here
|
self.dob = str(row[6]) # shouldn't return None here
|
||||||
self.nationality = str(row[7])
|
self.nationality = str(row[7])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class Driver(db.Model):
|
|||||||
code: Mapped[str] = mapped_column(String(8))
|
code: Mapped[str] = mapped_column(String(8))
|
||||||
forename: Mapped[str] = mapped_column(String(32))
|
forename: Mapped[str] = mapped_column(String(32))
|
||||||
surname: Mapped[str] = mapped_column(String(32))
|
surname: Mapped[str] = mapped_column(String(32))
|
||||||
dob: Mapped[dt.date] = mapped_column(Date)
|
dob: Mapped[str] = mapped_column(String(32))
|
||||||
nationality: Mapped[str] = mapped_column(String(32))
|
nationality: Mapped[str] = mapped_column(String(32))
|
||||||
|
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ class Result(db.Model):
|
|||||||
self.milliseconds = optional_int(row[12])
|
self.milliseconds = optional_int(row[12])
|
||||||
self.fastestLap = optional_int(row[13])
|
self.fastestLap = optional_int(row[13])
|
||||||
self.rank = optional_int(row[14])
|
self.rank = optional_int(row[14])
|
||||||
self.fastestLapTime = optional_time(row[15])
|
self.fastestLapTime = optional_str(row[15])
|
||||||
self.fastestLapSpeed = optional_str(row[16])
|
self.fastestLapSpeed = optional_str(row[16])
|
||||||
self.statusId = int(row[17])
|
self.statusId = int(row[17])
|
||||||
return self
|
return self
|
||||||
@ -186,7 +186,7 @@ class Result(db.Model):
|
|||||||
milliseconds: Mapped[Optional[int]] = mapped_column(Integer)
|
milliseconds: Mapped[Optional[int]] = mapped_column(Integer)
|
||||||
fastestLap: Mapped[Optional[int]] = mapped_column(Integer)
|
fastestLap: Mapped[Optional[int]] = mapped_column(Integer)
|
||||||
rank: Mapped[Optional[int]] = mapped_column(Integer)
|
rank: Mapped[Optional[int]] = mapped_column(Integer)
|
||||||
fastestLapTime: Mapped[Optional[dt.time]] = mapped_column(Time)
|
fastestLapTime: Mapped[Optional[str]] = mapped_column(String(32))
|
||||||
fastestLapSpeed: Mapped[Optional[str]] = mapped_column(String(16))
|
fastestLapSpeed: Mapped[Optional[str]] = mapped_column(String(16))
|
||||||
statusId: Mapped[int] = mapped_column(ForeignKey("status.statusId"))
|
statusId: Mapped[int] = mapped_column(ForeignKey("status.statusId"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user