Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
数据库替换查询在python中不起作用_Python_Replace_Rethinkdb - Fatal编程技术网

数据库替换查询在python中不起作用

数据库替换查询在python中不起作用,python,replace,rethinkdb,Python,Replace,Rethinkdb,我正在尝试使用replace关键字替换现有文档,但它不起作用。有人能告诉我,除了这个,我还应该做些什么吗 r.db("Siyara2D").table("Vessels").get(1).replace({ "x": "2222", "y": "1111", }).run(db_connection) 如果出现错误,请执行以下操作: Inserted object must have primary key `id` 解决方案是将主键

我正在尝试使用replace关键字替换现有文档,但它不起作用。有人能告诉我,除了这个,我还应该做些什么吗

  r.db("Siyara2D").table("Vessels").get(1).replace({
            "x": "2222",
            "y": "1111",

  }).run(db_connection)

如果出现错误,请执行以下操作:

Inserted object must have primary key `id`
解决方案是将主键保留在文档中。例如:

r.db("Siyara2D").table("Vessels").get(1).replace({
    "id": 1,
    "x": "2222",
    "y": "1111",
}).run(db_connection)