Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use flask-sqlalchemy with pycharm

I'm working with pyCharm, and been trying to install the sqlalchemy package to help me connect to my mysql db. I've run

pip install flask-sqlalchemy 

which completed successfully after downloading a bunch of files, but still the library isn't available when I do:

from flask.ext.sqlalchemy import SQLAlchemy

I'm pretty new to python and all this stuff, and I can't figure out what to do. Installing flask was easy because pyCharm sort of did that for me, is there any way to do something similar with this?

EDIT: I have managed to do this by opening pyCharm's preferences, then going to Project Interpreter, which displays all of the installed modules. Then simply click the + button at the bottom, and search for the required module... PyCharm did everything for me from that point.

like image 650
Luoruize Avatar asked Aug 31 '26 07:08

Luoruize


1 Answers

What works great when working with pyCharm and dependencies is to create a requirements.txt at the root of the project and add all of the packages required for your project.

With that pyCharm will auto-detect the requirements.txt file and ask you if you want to download the dependencies automatically.

In your case you could have tried to create a requirements.txt with:

flask
flask-sqlalchemy 
like image 90
Sylhare Avatar answered Sep 02 '26 11:09

Sylhare