I have a site that I\'ve built with Flask SQLAlchemy and SQLite, and need to switch to MySQL. I have migrated the database itself and have it running under MySQL, but
The accepted answer was correct at the time, but the syntax in the import statement has been deprecated.
This:
from flask.ext.sqlalchemy import SQLAlchemy
Should be replaced with:
import flask_sqlalchemy
Since questions regarding database connections tend to get traffic and stay relevant for a long time, it's worth having on the record.
The deprecation is in the Flask Version 1.0 Changelog, which actually uses this module in the example:
flask.ext - import extensions directly by their name instead of through the flask.ext namespace. For example, import flask.ext.sqlalchemy becomes import flask_sqlalchemy.