Ok, so I've got the following error when I try to login using my form:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
The code I've used to create my class for the database is:
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(30), unique=True)
email = db.Column(db.String(60), unique=True)
password = db.Column(db.String(50))
The initialization and configuration for my database(I've used SQLAlchemy) is the following piece of code:
movie_recommendation.config['SECRET_KEY'] = secret_key
movie_recommendation.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///c/Users/gheor/Documents/login-example/database.db'
bootstrap = Bootstrap(movie_recommendation)
db = SQLAlchemy(movie_recommendation)
login_manager = LoginManager()
login_manager.init_app(movie_recommendation)
login_manager.login_view = 'login'
Also, the code for register and login forms is the following(note: this seems to work just fine, it seems to be an issue just regarding my database) :
class LoginForm(FlaskForm):
username = StringField('Username', validators=[InputRequired(), Length(min=10, max=30)])
password = PasswordField('Password', validators=[InputRequired(), Length(min=10, max=50)])
remember = BooleanField('Remember me!')
class RegisterForm(FlaskForm):
email = StringField('Email', validators=[InputRequired(), Length(max=60)])
username = StringField('Username', validators=[InputRequired(), Length(min=10, max=30)])
password = PasswordField('Password', validators=[InputRequired(), Length(min=10, max=50)])
I apologize if this is a dumb question, but I'm pretty newbie using Flask and SQLAlchemy, and I really don't know how to modify that code to work fine. So any help will me really appreciated.