此数据库不支持Sql API错误 [英] Sql api is not supported for this database Error

查看:91
本文介绍了此数据库不支持Sql API错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Cdata 在Cosmo DB Mongo API中执行查询>通过Python进行ODBC.下面是驱动程序配置:

I'm trying to execute a query in Cosmo DB Mongo API, using the Cdata ODBC through Python. Below is the driver configuration:

[CData ODBC Driver for Cosmos DB]
Description=CData ODBC Driver for Cosmos DB 2019
Driver=/opt/cdata/cdata-odbc-driver-for-cosmosdb/lib/libcosmosdbodbc.x86.so
UsageCount=1
Driver64=/opt/cdata/cdata-odbc-driver-for-cosmosdb/lib/libcosmosdbodbc.x64.so

这是我用来进行查询的代码:

This is the code I'm using to make the query:

import pyodbc

cnxn = pyodbc.connect("DRIVER={CData ODBC Driver for Cosmos DB};AccountEndpoint=https://[myhost].com:443/;AccountKey=[mypass];")
cursor = cnxn.cursor()

# Find Schemas
cursor.tables()
for (catalog, schema, table, table_type, description) in cursor:
    print("Catalog: {}, Schema: {}, Table: {}, Type: {}".format(
        catalog, schema, table, table_type
    ))

# Execute Query  
cursor.execute("SELECT luistest from luistest")
rows = cursor.fetchall()
for row in rows:
  print(row.luistest)

执行它时,表和方案的查询返回良好,但是当我查阅文档时,收到以下错误:

When I execute it, the query of the tables and schemes returns good, but when I consult the documents I receive the following error:

Catalog: CData, Schema: luis-test, Table: luistest, Type: TABLE
Traceback (most recent call last):
  File "mongo_odbc_test.py", line 11, in <module>
    cursor.execute("SELECT luistest from luistest")
pyodbc.Error: ('HY000', '[HY000] [Forbidden] Sql api is not supported for this database account\r\nActivityId: 66808c80-83b6-4694-99ac-295693b8f51d, Microsoft.Azure.Documents.Common/2.5.1.  (-1) (SQLExecDirectW)')

我有一个学生Azure帐户,这可能会产生影响吗?使用此工具可以在没有SQL的情况下进行查询吗?

I have a student Azure account, could this affect? Is it possible to make a query without SQL with this tools?

谢谢.

推荐答案

该工具似乎正在使用SQL API运行SQL查询.如果您的Cosmos DB帐户使用的是Mongo API,则应使用使用Mongo API的工具和驱动程序.

This tool seems to be using the SQL API to run SQL Queries. If your Cosmos DB account is using the Mongo API, you should be using tools and drivers that use the Mongo API.

如果您打算使用此工具作为主要的开发/用例,我会认为Mongo API帐户可能不是正确的选择,因为您没有Mongo要求,只需创建一个SQL(核心)API帐户即可.

If you are going to use this tool as your main development/use case, I would argue that Mongo API account might not be the correct choice as you have no Mongo requirements, just create a SQL (Core) API account.

这篇关于此数据库不支持Sql API错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆