File E:\python3.7.7\lib\site-packages\flask_sqlalchemy\extension.py, line 308, in init_app Either SQLALCHEMY_DATABASE_URI or SQLALCHEMY_BINDS must be set. RuntimeError: Either SQLALCHEM
时间: 2023-11-16 13:06:55 浏览: 45
Y_DATABASE_URI or SQLALCHEMY_BINDS must be set is a common error in Flask-SQLAlchemy. This error is raised when the Flask application is not configured properly to use SQLAlchemy.
To fix this error, you need to set the SQLALCHEMY_DATABASE_URI configuration variable in your Flask application configuration. This variable should contain the connection string for your database.
Here is an example of how to set the SQLALCHEMY_DATABASE_URI variable:
```
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://user:password@localhost/mydatabase'
```
You can also set the SQLALCHEMY_BINDS variable if you need to connect to multiple databases.
Once you have set the configuration variables, you should be able to initialize the Flask-SQLAlchemy extension without any errors.