0
from flask import Flask, render_template,redirect, 
session,url_for,request
from flask_mysqldb  import MYSQl
app = Flask(__name__)
app.secret_key="12345678"

app.config["MYSQL_HOST"] = "localhost"
app.config["MYSQL_USER"]="root"
app.config["MYSQL_PASSWORD"]="123457"
app.config["MYSQL_DB"] = "management"
db = MYSQL(app)

This is the library code in vs code that do not show error here

In this snap showing import error while library already installed

This is the snap of flask mysqldb installed

I installed mysql. but when i run in python it giving error how do i remove import error for flask_mysqldb.In second snap showing import error while library already installed.In third snap, This is the snap of flask mysqldb is installed

3
  • 2
    Please add code and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. Commented Sep 19, 2021 at 13:39
  • 2
    Why do you think from flask import MYSQL should work? Commented Sep 19, 2021 at 13:40
  • because i am working on this library. i use this for accessing MySQL data Commented Sep 19, 2021 at 13:47

2 Answers 2

1

For import MySQL in flask. The Syntax are from flask_mysqldb import MySQL. 'y' always in lowercase in " MySQL"

Sign up to request clarification or add additional context in comments.

Comments

0

**Did you install flask-mysql? **

If you haven't, Install it by running the following command in command prompt.

pip install flask-mysql

If you've already installed flask-mysql, as I can see from the screenshots of the error your import statement is incorrect,

Import it as:

from flask_mysql import MySQL

4 Comments

This line giving same error on flaskext .mysql
Probably MySQL, not MYSQL.
but still giving error by MySQL
I replace MYSQL with MySQL. In my previous library it will solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.