编程语言
首页 > 编程语言> > 尝试使用Python重新思考时“ rethinkdb.errors.ReqlServerCompileError:预期有2个参数,但在其中找到1个:”

尝试使用Python重新思考时“ rethinkdb.errors.ReqlServerCompileError:预期有2个参数,但在其中找到1个:”

作者:互联网

我正在使用Python模块使用RethinkDB,现在我正在尝试使用以下语句更新模型:

results = rethink.table(model + "s").filter(id=results["id"]).update(data).run(g.rdb_conn)

模型是在函数的前面定义的,在这种情况下,它是引号,数据是JSON数据的字典:

{
    "channelId": "paradigmshift3d",
    "quoteId": "1",
    "quote": "Testing 123",
    "userId": "123",
    "messageId": "456"
}

根据RethinkDB API reference,我正在使用的语句应该有效,但事实并非如此.这是完整的追溯:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/nate/CactusAPI/views.py", line 309, in chan_quote
    fields=fields
  File "/home/nate/CactusAPI/helpers.py", line 403, in generate_response
    ).update(data).run(g.rdb_conn)
  File "/usr/local/lib/python3.5/dist-packages/remodel/monkey.py", line 18, in remodel_run
    return run(self, c, **global_optargs)
  File "/usr/local/lib/python3.5/dist-packages/rethinkdb/ast.py", line 118, in run
    return c._start(self, **global_optargs)
  File "/usr/local/lib/python3.5/dist-packages/rethinkdb/net.py", line 620, in _start
    return self._instance.run_query(q, global_optargs.get('noreply', False))
  File "/usr/local/lib/python3.5/dist-packages/rethinkdb/net.py", line 466, in run_query
    raise res.make_error(query)
rethinkdb.errors.ReqlServerCompileError: Expected 2 arguments but found 1 in:
r.table('quotes').filter(id='92c5160a-db57-4c3b-b2b2-2704cdcfc2b7').update(r.expr({'channelId': 'paradigmshift3d', 'quoteId': '1', 'quote': 'Testing 123', 'userId': '123', 'messageId': '456'}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

我已经进行了一些谷歌搜索,但是似乎没有关于此问题的任何问题.

解决方法:

这是由我尝试使用单个参数执行.filter()引起的. .filter()需要一个字典,我只是提供id = 92c5160a-db57-4c3b-b2b2-2704cdcfc2b7′.

我将查询更改为

rethink.table(model“ s”).get(results [“ id”]).update(data).run(g.rdb_conn)

现在正在工作!

标签:rethinkdb,python,rethinkdb-python
来源: https://codeday.me/bug/20191118/2026883.html