Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

41 lines
1.5KB

  1. # @name: models.py
  2. # @version: 0.1
  3. # @creation_date: 2021-10-20
  4. # @license: The MIT License <https://opensource.org/licenses/MIT>
  5. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  6. # @purpose: Database models for tables in the database
  7. # @acknowledgements:
  8. # https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login
  9. from flask_login import UserMixin
  10. from . import db
  11. from datetime import datetime
  12. # table for users
  13. class User(UserMixin, db.Model):
  14. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  15. email = db.Column(db.String(100), unique=True)
  16. password = db.Column(db.String(100))
  17. name = db.Column(db.String(1000))
  18. # table for tools
  19. class Tool(db.Model):
  20. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  21. created = db.Column(db.DateTime, default=datetime.utcnow)
  22. name = db.Column(db.Text)
  23. description = db.Column(db.Text)
  24. # table for examples
  25. class Example(db.Model):
  26. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  27. created = db.Column(db.DateTime, default=datetime.utcnow)
  28. name = db.Column(db.Text)
  29. description = db.Column(db.Text)
  30. # table for examples
  31. class Practice(db.Model):
  32. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  33. created = db.Column(db.DateTime, default=datetime.utcnow)
  34. name = db.Column(db.Text)
  35. description = db.Column(db.Text)