Sunday, 5 January 2020

ERROR [root] Error: Target database is not up to date. - Python Flask


 While working on the python flask I got the below error and when I tried to debug more then I reliaze that this is not the culprit.



  1.     self.dialect.do_execute(
  2.   File "C:\Program Files\Python38\lib\site-packages\sqlalchemy\engine\default.py", line 552, in do_execute
  3.     cursor.execute(statement, parameters)
  4. sqlalchemy.exc.OperationalError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
  5. (sqlite3.OperationalError) no such table: user
  6. [SQL: INSERT INTO user (username, email, password_hash) VALUES (?, ?, ?)]
  7. [parameters: ('Vipin', 'XX.i.kumar@gmail.com', None)]
  8. (Background on this error at: http://sqlalche.me/e/e3q8)



Now When the ouput of the command falsk db migrate been checked, then got the root issue, problem was 

  warnings.warn(
c:\program files\python38\lib\site-packages\flask_sqlalchemy\__init__.py:834: 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.
  warnings.warn(FSADeprecationWarning(
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [root] Error: Target database is not up to date.

After reading a number of post concluded issue the the new migration folder which get created when we run the follwoing command.

flask db migrate


Now I rename the migration folder to xmigration. then re-run the script from

flask db init
flask db migrate -m 'user table'

Now it created the migration folder again and then next command also a success.

I am still not able to reach to root of the issue, will see it in some time, but till then happy solutioning.



No comments:

Post a Comment

Feature Selection in AI

In artifical intelegance/machine learning, everything start and end with data and in current world everyday by using facebook, insta we all ...