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

flask 数据迁移的更多相关文章

  1. flask-sqlalchemy使用及数据迁移

    flask-sqlalchemy是flask框架在sqlalchemy基础上改造的一个orm框架 现在有两个实体Article文章和Category分类 一个分类下可能有多篇文章 相关示例: 项目相关 ...

  2. Flask入门之触发器,事件,数据迁移

    SQLAlchemy Core和SQLAlchemy ORM都具有各种各样的事件挂钩: 核心事件 - 这些在 Core Events中描述,并包括特定于连接池生命周期,SQL语句执行,事务生命周期以及 ...

  3. Flask (三) 数据迁移

    数据迁移 安装 pip install flask-migrate 初始化 使用app和db进行migrate对象初始化   from flask_migrate import Migrate mig ...

  4. Flask 数据库迁移

    在开发过程中,需要修改数据库模型,而且还要在修改之后更新数据库.最直接的方式就是删除旧表,但这样会丢失数据. 更好的解决办法是使用数据库迁移框架,它可以追踪数据库模式的变化,然后把变动应用到数据库中. ...

  5. Flask_Flask-Migrate数据迁移扩展(十二)

    在开发过程中,需要修改数据库模型,而且还要在修改之后更新数据库.最直接的方式就是删除旧表,但这样会丢失数据.更好的解决办法是使用数据库迁移框架,它可以追踪数据库模式的变化,然后把变动应用到数据库中. ...

  6. 【SQLServer】记一次数据迁移-标识重复的简单处理

    汇总篇:http://www.cnblogs.com/dunitian/p/4822808.html#tsql 今天在数据迁移的时候因为手贱遇到一个坑爹问题,发来大家乐乐,也传授新手点经验 迁移惯用就 ...

  7. Entity Framework Code First Migrations--EF 的数据迁移

    1. 为了演示方便,首先新建一个控制台项目,然后添加对entityframework的引用 使用nuget控制台执行: Install-Package EntityFramework 2.新建一个实体 ...

  8. mssql与mysql 数据迁移

    概要: mssql向mysql迁移的实例,所要用到的工具bcp和load data local infile. 由于订单记录的数据是存放在mssql服务器上的,而项目需求把数据迁移到mysql ser ...

  9. 重置EntityFramework数据迁移到洁净状态

    前言 翻译一篇有关EF数据迁移的文章,以备日后所用,文章若有翻译不当的地方请指出,将就点看,废话少说,看话题.[注意]:文章非一字一句的翻译,就重要的问题进行解释并解决. 话题引入 无法确定这种场景是 ...

随机推荐

  1. python mysql基本操作

    1.创建数据库.表添加数据. # -*- coding: utf-8 -*- import MySQLdb.cursors conn =MySQLdb.connect(',charset = 'utf ...

  2. 从hello world 说程序运行机制

    转自:http://www.cnblogs.com/yanlingyin/archive/2012/03/05/2379199.html 开篇 学习任何一门编程语言,都会从hello world 开始 ...

  3. ASP.NET常用标准配置web.config

    在我们的项目开发过程中,我们经常要配置wei.config文件,而大多数的时候配置差不多,下面的是一个简单的配置,其他的配置可以在这个基础上在添加 <?xml version="1.0 ...

  4. Java多线程编程核心技术,第一章

    1,Java并发--详解this与Thread.currentThread()的区别:https://blog.csdn.net/championhengyi/article/details/7666 ...

  5. win7怎么安装和启动 jboss

    本文以JBoss Application Server 4.2.1 GA(以下简称JBoss)为例,介绍它在Windows平台上的启动过程.为了方便叙述,对平台环境做以下假定:Java运行时的安装路径 ...

  6. SharePoint中使用Visio Service展示业务数据

    SharePoint中可以通过Visio Service可以在浏览器中查看Visio图,功能部署到系统中,一切安好. 而现实总是很折磨人,使用该功能后,相关使用者随后提出,Visio图能否与我的业务数 ...

  7. jsp中取两位小数

    var d=1.11111111;  var c = d.toFixed(2);  alert(c);

  8. Memory stream is not expandable

    发现项目有一个地方在做图片缩放剪切的一个操作中.碰到有一些特殊的图片会报 Memory stream is not expandable 的错误 跟踪的时候发现是 由方法 originalStream ...

  9. 让html标签显示在页面上

    用 <xmp></xmp> 标签包起来,里面的所有文字会原样显示出来 <xmp><b>1</b><div>2</div&g ...

  10. 国内DP厂家的相关资料信息

    这两天看了国内各个厂家的DSP开发板,总结一下,希望给同样需要的人一点经验和总结. 因为我是做通信系统,所以需要TI公司的C6000系列处理器. 目前C6000系列性能最强的是C66X系列,该系列的C ...