models.py

mail@pastecode.io avatar
unknown
python
a year ago
1.4 kB
18
Indexable
Never

from sqlalchemy import Column, String, Integer, Float, ForeignKey, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship

Base = declarative_base()

class train(Base):
    __tablename__ = "Train"

    train_id = Column(Integer, primary_key=True)
    name = Column(String)
    longDescription = Column(String)
    shortDescription = Column(String)
    imageUrl = Column(String)
    rating = Column(Float)
    ridesPerDay = Column(Integer)
    stations = relationship("Station", backref="Train")
    changeNum = Column(Integer)
    reservations = relationship("Reservations", backref="train")

class Station(Base):
    __tablename__ = "station"

    station_id = Column(Integer, primary_key=True)
    train_id = Column(Integer, ForeignKey("Train.train_id"))
    name = Column(String)


class ticket(Base):
    __tablename__ = "ticket"

    ticket_id = Column(Integer, primary_key=True)
    train_id = Column(Integer, ForeignKey("ticket.train_id"))
    departureTime = Column(DateTime)
    arrivalTime = Column(DateTime)
    capacity = Column(Integer)
    classNumber = Column(Integer)
    price = Column(Integer)

class Reservations(Base):
    __tablename__ = "reservations"

    name = Column(String, ForeignKey("Train.name"))
    ReservationID = Column(Integer, primary_key=True)
    fName = Column(String)
    lName = Column(String)
    personalID = Column(String)
    mail = Column(String)