【问题标题】:How to insert the result of a n1ql to a bucket using python SDK couchbase如何使用 python SDK couchbase 将 n1ql 的结果插入存储桶
【发布时间】:2019-08-02 10:25:43
【问题描述】:

我想使用 python 将 n1ql 的结果插入到存储桶“测试”中,但我不知道该怎么做,我是新手。

我使用 couchbase 搜索了文档 python SDK,但没有找到我正在努力解决的问题的答案。我不知道如何使用 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 ")

我希望将结果放入存储桶“测试”中。

【问题讨论】:

    标签: python couchbase bucket


    【解决方案1】:

    使用 INSERT INTO SELECT 语句。示例 8, 13-15 https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/insert.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多