如何使用 python SDK couchbase 将 n1ql 的结果插入存储桶

How to insert the result of a n1ql to a bucket using python SDK couchbase

我想使用 python 将 n1ql 的结果插入存储桶 'test',但我不知道如何操作,我是新手。

我搜索了文档 python 使用 couchbase 的 SDK,但没有找到我正在努力解决的问题的答案 with.I 不知道如何为此使用 upsert()..

from couchbase.cluster import Cluster
from couchbase.cluster import PasswordAuthenticator
from couchbase.n1ql import N1QLQuery
cluster = Cluster('couchbase://localhost:8091')
authenticator = PasswordAuthenticator('Administrator', 'root123')
cluster.authenticate(authenticator)
cb = cluster.open_bucket('test')
cb = cluster.open_bucket('pth')
cb.operationTimeout = 5000;
#N1QL Simple Query#
query = N1QLQuery("SELECT usr_id,score FROM pth ")

我想将结果放入存储桶'test'。

使用 INSERT INTO SELECT 语句。 https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/insert.html

处的示例 8、13-15