Forums

sqlalchemy.exc.ProgrammingError: Character set '255' unsupported

I am getting the following error and I'm not sure how to fix it. I am trying to use Flask-SQLAlchemy and Flask-Migrate to help with managing a mysql database. I set up a database on pythonanywhere.

After running

flask db migrate
flask db upgrade

I get the following error.

sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) Character set '255' unsupported
(Background on this error at: https://sqlalche.me/e/14/f405)

I am using a virtual environment I created on PythonAnywhere (Python 3.9.13) with the following relevant packages installed:

alembic==1.9.0
Flask==2.2.2
Flask-Migrate==4.0.0
Flask-SQLAlchemy==3.0.2
mysql==0.0.3
mysql-connector-python==8.0.31
mysqlclient==2.1.1
python-dotenv==0.21.0
SQLAlchemy==1.4.45

I tried to setup my database in the way described by this tutorial: https://blog.pythonanywhere.com/121/

Thanks in advance!

mysql-connector is not well supported by sqlalchemy (https://docs.sqlalchemy.org/en/14/dialects/mysql.html#module-sqlalchemy.dialects.mysql.mysqlconnector). Try using different mysql library (like pyMySQL) instead

Thank you so much! I think I got it working now. For anyone seeing this in the future, I also had to change mysql+mysqlconnector to just mysql for my SQLALCHEMY_DATABASE_URI variable.

thanks