文章内容

2018/9/11 11:21:27,作 者: 黄兵

INFO [alembic.runtime.migration] Context impl MySQLImpl.

最近使用SQLAlchemy更新数据库,一直不成功,具体提示如下:

(venv) E:\Python\SMS_Receive>python manage.py db upgrade

E:\Python\SMS_Receive\venv\lib\site-packages\flask_sqlalchemy\__init__.py:794: 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 '

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

代码如下:

# Token相关表
class TokenList(db.Column):
    __tablename__ = 'tokenlist'
    id = db.Column(db.Integer, primary_key=True)
    Token = db.column(db.String(0, 36))

检查了半天原来是这里写错完了:

class TokenList(db.Column):

修改代码:

# Token相关表
class TokenList(db.Model):
    __tablename__ = 'tokenlist'
    id = db.Column(db.Integer, primary_key=True)
    Token = db.column(db.String(0, 36))

之后再次执行,终于可以更新数据库了。

(venv) E:\Python\SMS_Receive>python manage.py db migrate -m "add tokenlist"

E:\Python\SMS_Receive\venv\lib\site-packages\flask_sqlalchemy\__init__.py:794: 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 '

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

INFO  [alembic.autogenerate.compare] Detected added table 'tokenlist'

Generating E:\Python\SMS_Receive\migrations\versions\f2b0255c8918_add_tokenlist.py ... done

向数据库提交更改,具体提示如下:

(venv) E:\Python\SMS_Receive>python manage.py db upgrade

E:\Python\SMS_Receive\venv\lib\site-packages\flask_sqlalchemy\__init__.py:794: 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 '

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

INFO  [alembic.runtime.migration] Running upgrade  -> f2b0255c8918, add tokenlist


问题总算解决。


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - INFO  [alembic.runtime.migration] Context impl MySQLImpl.

分享到:

发表评论

评论列表