Aug-31-2020, 08:26 PM
(This post was last modified: Aug-31-2020, 08:26 PM by marcello86.)
Hi there! I need urgent help, I have been stuck on this for days now.
My app needs the FTP password to ftp some file to another PC, I can't write the static password in the code so I have to encrypt it and store it in a db, SQLAlchemy in this case.
It returns the following error though:
My app needs the FTP password to ftp some file to another PC, I can't write the static password in the code so I have to encrypt it and store it in a db, SQLAlchemy in this case.
It returns the following error though:
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$IqFjS8XRxNiUDtJ4LFMUn.PNEF3VRT1fev57Bqjgh3VV/HX16ew.W')]I have implemented the following class User that should (in theory) create a table with 3 columns in an existing db.
store_user_db.py: import os basedir = os.path.abspath(os.path.dirname(__file__)) from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_bcrypt import Bcrypt app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite') bcrypt = Bcrypt(app) db = SQLAlchemy(app) class User(db.Model): 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)here in the application I import the class objects to store the user and password in the db table but somehow it doesn't find the column pwd. Any idea why?
from store_user_db import User, db DICP_FTP_DESTINATION_PSW=self.submit_pwd() user = User(username="ita_itf", pwd=DICP_FTP_DESTINATION_PSW) db.session.add(user) db.session.commit()