博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
flask 数据迁移
阅读量:5051 次
发布时间:2019-06-12

本文共 2855 字,大约阅读时间需要 9 分钟。

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

转载于:https://www.cnblogs.com/mhc-fly/p/8439835.html

你可能感兴趣的文章
java容器---------手工实现Linkedlist 链表
查看>>
three.js 性能优化的几种方法
查看>>
《梦断代码》读书笔记(三)
查看>>
FreeMarker解析json数据
查看>>
Java8 Lambda表达应用 -- 单线程游戏server+异步数据库操作
查看>>
次序+“选择不重复的记录”(3)——最大记录
查看>>
Codeforces 450 C. Jzzhu and Chocolate
查看>>
[Unity3D]Unity3D游戏开发MatchTarget的作用攀登效果实现
查看>>
ACdream 1115 Salmon And Cat (找规律&&打表)
查看>>
JSON、JSONP、Ajax的区别
查看>>
AngularJS学习篇(一)
查看>>
关于Xshell无法连接centos6.4的问题
查看>>
css3动画——基本准则
查看>>
javaweb常识
查看>>
Java注解
查看>>
web自己主动保存表单
查看>>
一个小的日常实践——高速Fibonacci数算法
查看>>
机器学些技法(9)--Decision Tree
查看>>
drf权限组件
查看>>
输入月份和日期,得出是今年第几天
查看>>