Error when using WHERE in Eve-SQLAlchemy: TypeError: find() got an unexpected keyword argument 'perform_count'
Error when using WHERE in Eve-SQLAlchemy: TypeError: find() got an unexpected keyword argument 'perform_count'
我正在使用 Eve-SQLAlchemy 访问 SQLite 数据库中的数据。我有一个 People
class:
class People(BaseModel):
'''Test class'''
__tablename__ = 'people'
id = Column(Integer, primary_key=True)
firstname = Column(String)
lastname = Column(String)
born = Column(Date)
REST API 可以很好地处理这个查询:
curl -s http://127.0.0.1:5000/people/1
{
"id": 1,
"firstname": "Isaac",
"lastname": "Newton",
"born": "1642-12-25",
"_updated": "Fri, 19 Apr 2019 14:03:08 GMT",
"_created": "Fri, 19 Apr 2019 14:03:08 GMT",
"_etag": "69a44481049920b40b7c06e651ed6c561f8b4892",
"_links": {
"self": {
"title": "People",
"href": "people/1"
},
"parent": {
"title": "home",
"href": "/"
},
"collection": {
"title": "people",
"href": "people"
}
}
}
但是,如果我尝试使用 WHERE
:
curl -s 'http://127.0.0.1:5000/people?where={"firstname":"Isaac"}'
我在服务器控制台中得到这个:
127.0.0.1 - - [22/Nov/2019 17:23:05] "GET /people?where="firstname":"Isaac" HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/flaskapp.py", line 1106, in __call__
return super(Eve, self).__call__(environ, start_response)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/endpoints.py", line 56, in collections_endpoint
response = get(resource, lookup)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/common.py", line 318, in rate_limited
return f(*args, **kwargs)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/auth.py", line 80, in decorated
return f(*args, **kwargs)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/common.py", line 1354, in decorated
r = f(resource, **combined_args)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/get.py", line 51, in get
return get_internal(resource, **lookup)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/get.py", line 125, in get_internal
return _perform_find(resource, lookup)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/get.py", line 266, in _perform_find
resource, req, lookup, perform_count=not config.OPTIMIZE_PAGINATION_FOR_SPEED
TypeError: find() got an unexpected keyword argument 'perform_count'
这是什么原因,我该如何解决?
Python 3.7,包版本:
Eve==0.9.2
Eve-SQLAlchemy==0.7.1
Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.11
您正在将 Eve-SQLAlchemy 与 尚未支持的 Eve 版本一起使用。 Eve-SQLAlchemy 0.7.1 支持 Eve<0.8
,但您使用的是 Eve==0.9.2
运行 pip install .
在 Eve-SQLAlchemy 的根目录中应该安装正确的依赖项,包括 Eve==0.7.10
.
我正在使用 Eve-SQLAlchemy 访问 SQLite 数据库中的数据。我有一个 People
class:
class People(BaseModel):
'''Test class'''
__tablename__ = 'people'
id = Column(Integer, primary_key=True)
firstname = Column(String)
lastname = Column(String)
born = Column(Date)
REST API 可以很好地处理这个查询:
curl -s http://127.0.0.1:5000/people/1
{
"id": 1,
"firstname": "Isaac",
"lastname": "Newton",
"born": "1642-12-25",
"_updated": "Fri, 19 Apr 2019 14:03:08 GMT",
"_created": "Fri, 19 Apr 2019 14:03:08 GMT",
"_etag": "69a44481049920b40b7c06e651ed6c561f8b4892",
"_links": {
"self": {
"title": "People",
"href": "people/1"
},
"parent": {
"title": "home",
"href": "/"
},
"collection": {
"title": "people",
"href": "people"
}
}
}
但是,如果我尝试使用 WHERE
:
curl -s 'http://127.0.0.1:5000/people?where={"firstname":"Isaac"}'
我在服务器控制台中得到这个:
127.0.0.1 - - [22/Nov/2019 17:23:05] "GET /people?where="firstname":"Isaac" HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/flaskapp.py", line 1106, in __call__
return super(Eve, self).__call__(environ, start_response)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/endpoints.py", line 56, in collections_endpoint
response = get(resource, lookup)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/common.py", line 318, in rate_limited
return f(*args, **kwargs)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/auth.py", line 80, in decorated
return f(*args, **kwargs)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/common.py", line 1354, in decorated
r = f(resource, **combined_args)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/get.py", line 51, in get
return get_internal(resource, **lookup)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/get.py", line 125, in get_internal
return _perform_find(resource, lookup)
File "/home/mark/projects/nlp_pipeline/venv/lib/python3.7/site-packages/eve/methods/get.py", line 266, in _perform_find
resource, req, lookup, perform_count=not config.OPTIMIZE_PAGINATION_FOR_SPEED
TypeError: find() got an unexpected keyword argument 'perform_count'
这是什么原因,我该如何解决?
Python 3.7,包版本:
Eve==0.9.2
Eve-SQLAlchemy==0.7.1
Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.11
您正在将 Eve-SQLAlchemy 与 尚未支持的 Eve 版本一起使用。 Eve-SQLAlchemy 0.7.1 支持 Eve<0.8
,但您使用的是 Eve==0.9.2
运行 pip install .
在 Eve-SQLAlchemy 的根目录中应该安装正确的依赖项,包括 Eve==0.7.10
.