zoukankan      html  css  js  c++  java
  • flask 数据迁移

    python flasky.py shell

    db.create_all()

    from app.models import User

    mhc = User("mhc")

    >>> db.session.add(mhc)
    >>> db.session.commit()

    -----------------------------------------

    if __name__ == '__main__':
    manager = Manager(app)
    manager.add_command('shell', Shell(make_context=make_shell_context))
    manager.add_command('db', MigrateCommand)
    manager.run()

    -----------------------------------------------

    (flask_env)[root@k8s3 flasky]# python flasky.py db init
    Creating directory /root/github/flasky/migrations ... done
    Creating directory /root/github/flasky/migrations/versions ... done
    Generating /root/github/flasky/migrations/README ... done
    Generating /root/github/flasky/migrations/alembic.ini ... done
    Generating /root/github/flasky/migrations/env.py ... done
    Generating /root/github/flasky/migrations/script.py.mako ... done
    Generating /root/github/flasky/migrations/env.pyc ... done
    Please edit configuration/connection/logging settings in '/root/github/flasky/migrations/alembic.ini' before proceeding.

    -------------------------------------------------------

    (flask_env)[root@k8s3 flasky]# python flasky.py db migrate -m "initial migration"
    /root/flask_env/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py:1569: Warning: '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
    cursor.execute('SELECT @@tx_isolation')
    INFO [alembic.runtime.migration] Context impl MySQLImpl.
    INFO [alembic.runtime.migration] Will assume non-transactional DDL.
    INFO [alembic.env] No changes in schema detected.

    ----------------------------------------

    (flask_env)[root@k8s3 flasky]# python flasky.py db migrate -m "add about_me2"
    /root/flask_env/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py:1569: Warning: '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
    cursor.execute('SELECT @@tx_isolation')
    INFO [alembic.runtime.migration] Context impl MySQLImpl.
    INFO [alembic.runtime.migration] Will assume non-transactional DDL.
    INFO [alembic.autogenerate.compare] Detected added column 'users.about_me2'
    Generating /root/github/flasky/migrations/versions/31817122665d_add_about_me2.py ... done
    (flask_env)[root@k8s3 flasky]#
    (flask_env)[root@k8s3 flasky]#
    (flask_env)[root@k8s3 flasky]# python flasky.py db upgrade
    /root/flask_env/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py:1569: Warning: '@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead
    cursor.execute('SELECT @@tx_isolation')
    INFO [alembic.runtime.migration] Context impl MySQLImpl.
    INFO [alembic.runtime.migration] Will assume non-transactional DDL.
    INFO [alembic.runtime.migration] Running upgrade -> 31817122665d, add about_me2

  • 相关阅读:
    springboot---web 应用开发-文件上传
    springboot --> web 应用开发-CORS 支持
    Springboot
    spring boot ---web应用开发-错误处理
    Spring Boot基础教程》 第1节工具的安装和使用
    jQuery第四课 点击 _选项卡效果一
    jQuery第三课 点击按钮 弹出层div效果
    jQuery第二课 点击弹出一个提示框
    jQuery第一课 加载页面弹出一个对话框
    NPIO 导出Execl
  • 原文地址:https://www.cnblogs.com/mhc-fly/p/8439835.html
Copyright © 2011-2022 走看看