如何解决使用 couchbase python SDK 从 python 执行 Couchbase sql 脚本文件
我是新手,我试图连接到 couchbase 存储桶并使用 python 获取 ddata,只是尝试了文档中给出的任何内容。它工作正常。现在我的问题是我想从文件中执行这个选择查询如何使用 python sdk 执行/运行 sql 文件。我不想采用打开文件并从那里读取查询的方法。
我们可以使用 cbq 实用程序执行 sql 脚本,但我不知道如何使用 SDK 执行此操作。请帮忙解决
def connect_db():
print(CONNSTR,authenticator)
cluster = Cluster(CONNSTR,ClusterOptions(authenticator))
static_bucket = cluster.bucket('test')
default_collection = static_bucket.default_collection()
return cluster,default_collection
def findall():
"""Returns list of matching airports and the source query"""
queryprep = "SELECT test FROM `test` where test='TotalDue'"
res = cluster.query(queryprep)
for row in res:
test = row['test']
print(test)
return res
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。