File "/usr/local/lib/python3.6/dist-packages/flask_sqlalchemy/__init__.py", line 972, in create_engine, referer: http://123.123.123.123/
[Tue Jul 21 12:09:17.446596 2020] [wsgi:error] [pid 2995] [client 117.96.57.241:57794] return sqlalchemy.create_engine(sa_url, **engine_opts), referer: http://123.123.123.123/
[Tue Jul 21 12:09:17.446600 2020] [wsgi:error] [pid 2995] [client 117.96.57.241:57794] File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/__init__.py", line 500, in create_engine, referer: http://123.123.123.123/
[Tue Jul 21 12:09:17.446606 2020] [wsgi:error] [pid 2995] [client 117.96.57.241:57794] return strategy.create(*args, **kwargs), referer: http://123.123.123.123/
[Tue Jul 21 12:09:17.446609 2020] [wsgi:error] [pid 2995] [client 117.96.57.241:57794] File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/strategies.py", line 87, in create, referer: http://123.123.123.123/dbapi = dialect_cls.dbapi(**dbapi_args), referer: http://123.123.123.123/File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi, referer: http://123.123.123.123/return __import__("MySQLdb"), referer: http://123.123.123.123/
ModuleNotFoundError: No module named 'MySQLdb', referer: http://123.123.123.123/
[Tue Jul 21 12:09:17.446637 2020] [wsgi:error] [pid 2995] [client 117.96.57.241:57794] , referer: http://123.123.123.123/
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
The error message you are seeing:
ModuleNotFoundError: No module named ‘MySQLdb’
indicates that the required MySQL driver for Python is not installed in your environment. You need to install theMySQLdb
package (also known asmysqlclient
) to interact with a MySQL database using SQLAlchemy.Here are the steps to set up the MySQL connection in a Flask app running on a WSGI production server:
Install MySQL Driver:
Run the following command to install the
mysqlclient
package:Configure Your Flask Application:
In your Flask application, you need to set up the database URI to point to your MySQL database:
Make sure to replace
username
,password
,localhost
, anddbname
with your actual database credentials and host information.Configure WSGI:
mod_wsgi
orgunicorn
, make sure that it is properly configured to serve your Flask application. You may need to refer to specific documentation depending on the WSGI server you are using.Restart Your WSGI Server:
Check Application Logs:
Best,
Bobby