can’t set attribute when connecting to sqlite database with flask-sqlalchemy”?

[ad_1]

Are you having problems with the issue “AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy“? How to fix it? In today’s article, I will provide solutions for you to solve the issues. Please follow the below steps to get the problem resolved now

How did “AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy” occur?

AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy

When you work with Python, you may get the issue AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy. Don’t worry, we are here to provide you solutions in order to resolve your problem.

How to fix “AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy”?

Question: How to Solve AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy ?Answer – SQLAlchemy is installed automatically as a dependency on Flask–SQLAlchemy. The latest version (1.4.0) contains the following breaking change. You will need to downgrade your version. Follow the steps below to downgrade.

Solution 1: DownGrade sqlalchemy Version

Simply Downgrade your version. Follow the steps below to downgrade.

Run to double-check that you are not affected by this issue

Solution 2

  1. Simply freeze your packages
  2. pip freeze > requirements.txt
  3. Your SQLAlchemy should be updated in your requirements.txt
  4. SQLAlchemy
  5. Reinstall the packages
  6. pip install-r requirements.txt

Solution 3

I just checked for this error and found that SQLAlchemy was automatically updated.

SQLAlchemy automatically installs as a dependency on Flask-SQLAlchemy. The latest version (1.4.0) includes the following breaking change.

The URL object is now an immutable named tuple. To modify a URL object, use the URL.set() method to produce a new URL object.

This issue was easily fixed by installing SQL Alchemy 1.3.23.

Relevant github issue tracking fixes: github.com/pallets/flask-sqlalchemy/issues/910

Final words

The above are useful solutions that can help you fix “AttributeError: can’t set attribute when connecting to sqlite database with flask-sqlalchemy” problem, if you can’t solve it well. Please leave a message.

[ad_2]

Source link