1 Star 0 Fork 0

jiandanti/NEWS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.py 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
aku 提交于 2018-08-30 08:54 . 修改版1
import datetime
import functools
# def user_login_data(f):
# @functools.wraps(f)
# def wrapper(*args, **kwargs):
# return f(*args, **kwargs)
#
# return wrapper
# @app.route('/news/<int:news_id>')
# @user_login_data
# def num1():
# print("aaa")
#
#
# # @app.route('/')
# @user_login_data
# def num2():
# print("bbbb")
#
# if __name__ == '__main__':
# print(num1.__name__)
# print(num2.__name__)
import random
from info import db
from info.models import User
from manage import app
def add_test_users():
users = []
now = datetime.datetime.now()
for num in range(0, 10000):
try:
user = User()
user.nick_name = "%011d" % num
user.mobile = "%011d" % num
user.password_hash = "pbkdf2:sha256:50000$SgZPAbEj$a253b9220b7a916e03bf27119d401c48ff4a1c81d7e00644e0aaf6f3a8c55829"
user.last_login = now - datetime.timedelta(seconds=random.randint(0, 2678400))
users.append(user)
print(user.mobile)
except Exception as e:
print(e)
# 手动开启一个app的上下文
with app.app_context():
db.session.add_all(users)
db.session.commit()
print('OK')
if __name__ == '__main__':
add_test_users()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jiandanti/NEWS.git
git@gitee.com:jiandanti/NEWS.git
jiandanti
NEWS
NEWS
master

搜索帮助