flask中的数据库操作(创建用户及角色)报错
>>> from hello import db
>>> db.drop_all()
>>> from hello import Role, User
>>> admin_role = Role(name='Admin')
>>> mod_role = Role(name='Moderator')
>>> user_role = Role(name='User')
>>> user_john = User(username='john', role=admin_role)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<string>", line 4, in __init__
File "e:\pythonproject\flask-future\venv\lib\site-packages\sqlalchemy\orm\state.py", line 480, in _initialize_instance
manager.dispatch.init_failure(self, args, kwargs)
File "e:\pythonproject\flask-future\venv\lib\site-packages\sqlalchemy\util\langhelpers.py", line 70, in __exit__
compat.raise_(
File "e:\pythonproject\flask-future\venv\lib\site-packages\sqlalchemy\util\compat.py", line 207, in raise_
raise exception
File "e:\pythonproject\flask-future\venv\lib\site-packages\sqlalchemy\orm\state.py", line 477, in _initialize_instance
return manager.original_init(*mixed[1:], **kwargs)
File "e:\pythonproject\flask-future\venv\lib\site-packages\sqlalchemy\orm\decl_base.py", line 1142, in _declarative_constructor
raise TypeError(
TypeError: 'username' is an invalid keyword argument for User