I am creating a flask webpage that stores user info and accounts. This will obviously require databases. It allows me to login then returns an argument error.
from flask import Flask, render_template, request, redirect, url_for, flash
from flask_sqlalchemy import SQLAlchemy
from werkzeug.security import generate_password_hash, check_password_hash
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///logininfo.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = 'your_secret_key'
db = SQLAlchemy(app)
# Create tables in the database
# logininfo tab
class User(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
password_hash = db.Column(db.String(128), nullable=False)
class SkillTreeType(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)
description = db.Column(db.Text)
class SkillTree(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)
description = db.Column(db.Text)
skill_tree_type_id = db.Column(db.Integer, db.ForeignKey('skill_tree_type.id'), nullable=False)
# Define the relationship between SkillTreeType and SkillTree
skill_tree_type = db.relationship('SkillTreeType', backref='skill_trees')
# Define the relationship between SkillTree and Skill
skills = db.relationship('Skill', backref='associated_skill_tree', lazy='dynamic')
class Skill(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)
description = db.Column(db.Text)
points = db.Column(db.Integer, default=0)
video_link = db.Column(db.String(255)) # Add this line for video links
skill_tree_id = db.Column(db.Integer, db.ForeignKey('skill_tree.id'), nullable=False)
# Define the relationship between Skill and SkillTree
skill_tree_relation = db.relationship('SkillTree', backref='skills', lazy='dynamic')
with app.app_context():
db.create_all()
I expect it to create the tables and then allow me to enter data into those tables.