Hi all I need urgent help I have been stuck on this for days!
I'm trying to create a table in an existing db with SQLAlchemy/SQLite where I have to store a user and password, but it returns an error saying the column pwd doesn't exist!
Am I missing something? Am I messig it up?
I still didn't quite understand, I followed all steps in some online tutorial but nothing still.
Here is the class object that I developed, then from another register form I try to store the pw from the application, but the error should be here in this code:
THIS IS THE ERROR
I'm trying to create a table in an existing db with SQLAlchemy/SQLite where I have to store a user and password, but it returns an error saying the column pwd doesn't exist!
Am I missing something? Am I messig it up?
I still didn't quite understand, I followed all steps in some online tutorial but nothing still.
Here is the class object that I developed, then from another register form I try to store the pw from the application, but the error should be here in this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import os basedir = os.path.abspath(os.path.dirname(__file__)) from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_bcrypt import Bcrypt from sqlalchemy import * app = Flask(__name__) engine = create_engine(app.config[ 'SQLALCHEMY_DATABASE_URI' ]) bcrypt = Bcrypt(app) db = SQLAlchemy(app) #CREATE TABLE meta = MetaData() userstable = Table( 'users' , meta, Column( 'id' , Integer, primary_key = True , autoincrement = True ), Column( 'username' , String, unique = True ), Column( 'pwd' , String)) meta.create_all(engine) class User(db.Model): #DEFINE COLUMNS TYPE id = db.Column(db.Integer(), primary_key = True , autoincrement = True ) username = db.Column(db.String( 64 ), unique = True ) pwd = db.Column(db.String( 128 )) def __init__( self ,username,pwd): #self.id=id self .username = username self .pwd = bcrypt.generate_password_hash(pwd) |
THIS IS THE ERROR
1 |
sqlalchemy.exc.OperationalError OperationalError: (sqlite3.OperationalError) table user has no column named pwd [SQL: INSERT INTO user (username, pwd) VALUES (?, ?)] [parameters: ( 'ita_itf' , '$2b$12$VmpTsd0o4uTLj0wGypGu7ujhzYHLlV8k9ekaIP1.yh5lUMMgOM4MC' )] |