Lerndatenbank/lernplattform/models.py

16 lines
548 B
Python
Raw Normal View History

2024-08-05 20:43:29 +02:00
from lernplattform import db
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
password = db.Column(db.String(60), nullable=False)
def __repr__(self):
return f"User('{self.username}', '{self.email}')"
def initialize_database():
from lernplattform import app
with app.app_context():
db.create_all()
print("Database and tables created successfully.")