justinarat / Teamify

0 stars 0 forks source link

Flask database #34

Closed dominictdavies closed 2 months ago

dominictdavies commented 2 months ago

Catch up on the week 8 lecture, switching the current sqlite database to one that can be spun-up through flask instead:

justinarat commented 2 months ago

TODO:

FAljanobi commented 2 months ago

what else should be done? the database is connected(?) and ad i look at the flask megatutorial there seems to be two methods to set up the model, either the one currently done or like from the flask tutorial copied below `

class User(db.Model):
  id: so.Mapped[int] = so.mapped_column(primary_key=True)
  username: so.Mapped[str] = so.mapped_column(sa.String(64), index=True,
                                              unique=True)
  email: so.Mapped[str] = so.mapped_column(sa.String(120), index=True,
                                           unique=True)
  password_hash: so.Mapped[Optional[str]] = so.mapped_column(sa.String(256))
  def __repr__(self):
      return '<User {}>'.format(self.username)

` should we be using db.Column or so.Mapped and so.mapped_column?

justinarat commented 2 months ago

Apparently so.mapped_column supersedes db.Column in the new version of sqlalchemy (from the top answer here), but I think we should just keep using db.Column cause it's what was taught in the lecture.