Samyak Jain
Samyak Jain

Reputation: 25

ImportError: cannot import name 'SQLALchemy' from 'flask_sqlalchemy' error in flask

I am new to flask and I am trying to learn flask-sqlalchemy. For that, I referred to their documentation: https://flask-sqlalchemy.palletsprojects.com/en/2.x/quickstart/#a-minimal-application

Here is my `__init__.py` file:

from flask import Flask 
from flask_sqlalchemy import SQLALchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)

from app import routes

So, when I import the db variable with from app import db command, I get this error:

Traceback (most recent call last):
  File "c:\users\dell\desktop\flask\tutorial\venv\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "C:\Users\Dell\Desktop\Flask\tutorial\app\__init__.py", line 2, in <module>
    from flask_sqlalchemy import SQLALchemy
ImportError: cannot import name 'SQLALchemy' from 'flask_sqlalchemy' (c:\users\dell\desktop\flask\tutorial\venv\lib\site-packages\flask_sqlalchemy\__init__.py)

Why am I getting this error? I read through a few stack overflow questions, but none of them helped me.

Upvotes: 0

Views: 1161

Answers (1)

Justin Ding
Justin Ding

Reputation: 465

it's SQLAlchemy not SQLALchemy - note the second L should be lowercase

Upvotes: 3

Related Questions