So I am trying to make a flask app login and i did this:
from flask import Flask, render_template, url_for
from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin
# from flask_wtf import wtforms
# from wtforms import StringField, PasswordField, SubmitField
# from wtforms.validators import InputRequired, Length,ValidationError
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
app.config['SECRET_KEY'] = 'thisisasecreatkey'
db = SQLAlchemy(app)
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), nullable=False, unique=True)
password = db.Column(db.String(80), nullable=False)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/login')
def login():
return render_template('login.html')
@app.route('/register')
def register():
return render_template('register.html')
if __name__ == '__main__':
app.run(debug = True)
with app.app_context():
db.create_all()
and to create a database also did this: from app import app,db
app.app_context().push() db.create_all()
then i got this error: sqlite3 database.db
The term 'sqlite3' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
the i am trying everything but it is not working please someone help me fast!!!
i have tried it in cmd prompt and it just say sqlite3 database.db SQLite version 3.45.2 2024-03-12 11:06:23 (UTF-16 console I/O) Enter ".help" for usage hints. sqlite>
but it should have user database/table created in it. PLEASE!!