我正在尝试借助 SQLAlchemy、Marshmallow 和 flask-restplus 使用单个表构建简单的 REST API。但它给出了 LookupError。
应用程序使用过程中出现以下错误:
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/enumerated.py", line 147, in _object_value_for_elem
return super(ENUM, self)._object_value_for_elem(elem)
File "/home/ec2-user/.local/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py", line 1483, in _object_value_for_elem
'"%s" is not among the defined enum values' % elem
LookupError: "DIVERSE" is not among the defined enum values
96.57.148.186 - - [27/Feb/2019 09:16:23] "GET /employee/114425 HTTP/1.1" 500 -
Run Code Online (Sandbox Code Playgroud)
我正在尝试将 Enums 与 Marshmallow 和 SQLAlchemy 一起使用。我应该放弃 Enums 并简单地在数据库中使用 String 字段并仅对 Marshmallow 进行验证吗?
service.py文件是:
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow …Run Code Online (Sandbox Code Playgroud) python sqlalchemy flask-sqlalchemy flask-restplus marshmallow