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