正如评论中所讨论的,这是解决方案,因此对其他人有帮助:
您需要定义一个会话并将其传递给 load 函数,如下所示:
from sqlalchemy import engine #thanks to your comment
from sqlalchemy.orm import scoped_session, sessionmaker
class UserRegister(Resource):
@classmethod
def post(cls):
# the 'load' function in marshmallow will use the data to create usermodel object
sess = scoped_session(sessionmaker(bind=engine))
user = user_schema.load(request.get_json(), sess)
守着一只汪
蝴蝶不菲
相关分类