1. 程式人生 > >SQLAlchemy版本回退操作(其他資料庫相關bug)

SQLAlchemy版本回退操作(其他資料庫相關bug)

1:track_modifications = app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] 報錯,需要進行flask的sqlalchemy版本進行回退操作

語句 pip install Flask-SQLAlchemy==2.1  

2:This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). 


解決辦法:增加回調函式
try:
    db.session.commit()
except:

    db.session.rollback()

3、C:\Python27\python.exe C:\Users\Jinjin\PycharmProjects\untitled8\zlktqa.py
C:\Python27\lib\site-packages\flask_sqlalchemy\__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
  warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.')
 * Restarting with stat
C:\Python27\lib\site-packages\flask_sqlalchemy\__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.
  warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True to suppress this warning.')
 * Debugger is active!
 * Debugger PIN: 168-863-100
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Detected change in 'C:\\Users\\Jinjin\\PycharmProjects\\untitled8\\config.py', reloading
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 168-863-100

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

解決辦法:在config函式(配置函式)中增加   SQLALCHEMY_TRACK_MODIFICATIONS =False語句

4、sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2003, "Can't connect to MySQL server on '10.66.121.159' (110)") (Background on this error at: http://sqlalche.me/e/e3q8)(伺服器上部署)

解決辦法: