Large database migration
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 15s
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 15s
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
from sqlalchemy import DateTime, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
@ -13,22 +12,11 @@ class DbRace(db.Model):
|
||||
"""
|
||||
__tablename__ = "race"
|
||||
|
||||
def __init__(self, *, name: str, number: int, date: datetime, pxx: int):
|
||||
self.name = name # Primary key
|
||||
def __init__(self, *, id: int):
|
||||
self.id = id # Primary key
|
||||
|
||||
self.number = number
|
||||
self.date = date
|
||||
self.pxx = pxx
|
||||
|
||||
@classmethod
|
||||
def from_csv(cls, row: List[str]):
|
||||
db_race: DbRace = cls(name=str(row[0]),
|
||||
number=int(row[1]),
|
||||
date=datetime.strptime(str(row[2]), "%Y-%m-%d-%H-%M"),
|
||||
pxx=int(row[3]))
|
||||
return db_race
|
||||
|
||||
name: Mapped[str] = mapped_column(String(64), primary_key=True)
|
||||
number: Mapped[int] = mapped_column(Integer)
|
||||
date: Mapped[datetime] = mapped_column(DateTime)
|
||||
pxx: Mapped[int] = mapped_column(Integer) # This is the place to guess
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=False)
|
||||
name: Mapped[str] = mapped_column(String(64), nullable=False, unique=True)
|
||||
number: Mapped[int] = mapped_column(Integer, nullable=False, unique=True)
|
||||
date: Mapped[datetime] = mapped_column(DateTime, nullable=False, unique=True)
|
||||
pxx: Mapped[int] = mapped_column(Integer, nullable=False) # This is the place to guess
|
||||
Reference in New Issue
Block a user