1 Star 0 Fork 0

MSN / test2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test2.py 911 Bytes
一键复制 编辑 原始数据 按行查看 历史
qinjinzhou_test2 提交于 2019-03-10 14:40 . 命令行添加
import logging
from flask import current_app
from flask import session
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from info import create_app, db
from info import models
from info.models import User
app=create_app('development')
manager=Manager(app)
Migrate(app,db)
manager.add_command('db',MigrateCommand)
@manager.option('-n', '-name', dest="name")
@manager.option('-p', '-password', dest="password")
def createsuperuser(name, password):
if not all([name, password]):
print("参数不足")
user = User()
user.nick_name = name
user.mobile = name
user.password = password
user.is_admin = True
try:
db.session.add(user)
db.session.commit()
except Exception as e:
db.session.rollback()
print(e)
print("添加成功")
if __name__ == '__main__':
print(app.url_map)
manager.run()
Python
1
https://gitee.com/usernameqin/test2.git
git@gitee.com:usernameqin/test2.git
usernameqin
test2
test2
master

搜索帮助