Python 如何在Flask restplus Api中使用基于方法参数的选择查询?
我想在我的Python 如何在Flask restplus Api中使用基于方法参数的选择查询?,python,mysql,select,peewee,flask-restplus,Python,Mysql,Select,Peewee,Flask Restplus,我想在我的Flask REST API中处理GET请求。该请求将包括List参数,我使用该参数作为典型的GET请求: https://localhost:5000/organisation?List=1 此请求将返回所有组织型号信息Organization是MySQL数据库表的模型类(bypeewee) 我想在请求中输入PrivenceId参数,并将返回所有organization模型信息,其中organization.PrivencedId==PrivenceId参数,但我遇到以下错误: Ty
Flask REST API
中处理GET
请求。该请求将包括List
参数,我使用该参数作为典型的GET请求:
https://localhost:5000/organisation?List=1
此请求将返回所有组织
型号信息Organization
是MySQL数据库表的模型类(bypeewee
)
我想在请求中输入PrivenceId
参数,并将返回所有organization
模型信息,其中organization.PrivencedId==PrivenceId
参数,但我遇到以下错误:
TypeError:“组织”对象不可编辑
我的代码(OrganizationController.py
文件)是:
运行api的boot.py
文件是:
from flask import Flask
from flask_restplus import Api
from Controllers import OrganisationController
app = Flask(__name__)
api = Api(app)
api.add_resource(OrganisationController.List, '/organisation')
if __name__ == "__main__":
app.run ('127.0.0.1', 5000, True)
你能帮我吗?我更改了这行代码并解决了我的问题:
Organisations = Organisation.select().where
(
Organisation.ProvinceId ==args['ProvinceId']
)
Organisations = Organisation.select().where
(
Organisation.ProvinceId ==args['ProvinceId']
)