20 lines
536 B
Python
20 lines
536 B
Python
from __init__ import app, db
|
|
from models import User
|
|
|
|
with app.app_context():
|
|
db.create_all()
|
|
|
|
if not User.query.filter_by(username='管理员').first():
|
|
admin = User(
|
|
username='管理员',
|
|
dingtalk_userid='admin',
|
|
dingtalk_name='管理员',
|
|
dingtalk_dept='',
|
|
role='admin'
|
|
)
|
|
db.session.add(admin)
|
|
db.session.commit()
|
|
print('数据库初始化完成,已创建管理员账户')
|
|
else:
|
|
print('数据库已存在')
|