Y
Y
Yupiter75752021-05-03 11:08:17
Flask
Yupiter7575, 2021-05-03 11:08:17

How to connect SQLAlchemy to Flask?

I seem to be doing everything right, but an error occurs:

C:\Main\lib\site-packages\flask_sqlalchemy\__init__.py:852: UserWarning: Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set. Defaulting SQLALCHEMY_DATABASE_URI to "sqlite:///:memory:".
  'Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set. '
C:\Main\lib\site-packages\flask_sqlalchemy\__init__.py:873: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '

I've already searched all over Google, the only thing I understood is the error here:
app = Flask(__name__)
app.config['SQLALCHEMY DATABASE_URI'] = 'sqlite:///myBase.db'
app.config['SQLALCHEMY TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
with app.app_context(): 
    db.create_all()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-05-03
@yupiter7575

This is not an error, but a warning. They crash because the configuration parameters are written incorrectly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question