Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I have started this today and received this over again and again and I have recreated the user also but it is not working. Please help me to debug it.
This is my app.py
from flask import Flask, jsonify, render_template, request
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://taran:1234@localhost/flask'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class Post(db.Model):
id = db.Column(db.Integer, primary_key = True)
title = db.Column(db.String(50), nullable = False)
body = db.Column(db.String(200), nullable = False)
date = db.Column(db.DateTime(timezone=True), default=datetime.now())
@app.route('/', methods = ['GET', 'POST'])
def home():
title = request.form.get('title')
body = request.form.get('body')
post = Post(title = title, body = body)
db.session.add(post)
db.session.commit()
return render_template('index.html')
if __name__ == "__main__":
app.run(debug= True)
This is the error coming
Please help
check if the password to access your SQL database is correct or else try changing your SQL root password to something else and try again. The above error is very similar to the one we commonly encounter while logging on to a website with the wrong password or username.
for changing the root password see the below video
https://youtu.be/izMuHGwXyjQ
If you don't have a password try either of this
Option 01:
SQLALCHEMY_DB_URI='mysql://root@localhost:<PORT>/<DB NAME>'
Option 02:
SQLALCHEMY_DB_URI='mysql://root:''@localhost:<PORT>/<DB NAME>'
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.