Esempio n. 1
0
def create_init_data():
    '''
    生成初始化数据
    '''
    datas = [
        {
            'id': 1,
            'group_type': 'SuperAdmin',
            'group_type_cn': '超级管理员'
        },
        {
            'id': 2,
            'group_type': 'Admin',
            'group_type_cn': '管理员'
        },
        {
            'id': 3,
            'group_type': 'NormalUser',
            'group_type_cn': '普通用户'
        }
    ]
    Group.insert_many(datas).execute()
    User.insert(username='******', password='******', group=1).execute()
Esempio n. 2
0
async def create_admin():
    mysql_engine = await create_engine(**DATABASE)
    async with mysql_engine.acquire() as conn:
        data = {
            'username': '******',
            'password': hash_password('adminsuperuser'),
            'email': '*****@*****.**',
            'first_name': 'Админ',
            'last_name': 'Админ',
            'role': ADMIN
        }

        query = User.insert().values(**data)
        await conn.execute(query)
        print('Admin created')