python - 如何使用 python SDK couchbase 将 n1ql 的结果插入存储桶
问题描述
我想使用 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 ")
我想将结果放入存储桶“测试”中。
解决方案
使用 INSERT INTO SELECT 语句。示例 8, 13-15 在 https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/insert.html
推荐阅读
- reactjs - create-react-app --typescript 默认文件中的 Typescript 错误 TS1005
- python - PIP 模块安装在 cmd 中,但 python 看不到它
- python - Cron 作业无法执行 python 脚本
- excel - 无法设置 ActiveCell 内部颜色
- vue.js - v-data-table 中的 Vuetify v-data-table:扩展项插槽中的内容故障
- c++ - 是否允许 const 数据成员在类外更改?
- flutter - Flutter SingleChildScrollView 不会滚动
- css - 在 CSS 中,overflow 和 float 是如何交互的?
- nlp - 如何从 spaCy 标记重建原始文本,即使在复杂的空白和标点符号的情况下
- r - 有没有可能通过 DCC GARCH (1,1) 代码自动运行几十只股票?