最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

OCI NoSQL query: PREPARE: Illegal Argument: The driver or SDK being used does not support complex query in python - Stack Overfl

programmeradmin4浏览0评论

I try to write a query to nosql Oracle Cloud with statement have count like below

nosql_client = oci.nosql.NosqlClient(config)
query = """
declare 
$Key string;

SELECT count(*) FROM log_table WHERE Key = $Key
"""
Key = "HV411"

try:    
    prepare_statement_response = nosql_client.prepare_statement(
    compartment_id=compartment_ocid,
    statement = query
    )
    rows_response = nosql_client.query(
    query_details=oci.nosql.models.QueryDetails(
    compartment_id=compartment_ocid,
    is_prepared = True,
    statement=prepare_statement_response.data.statement,
    consistency="EVENTUAL",
    variables = {
    '$Key':Key,
    }
    ),
    )
    print(rows_response)
except (Exception, ValueError) as ex:
    print('Failed to execute the query ' + str(ex))

I got this error

Failed to execute the query {'target_service': 'nosql', 'status': 400, 'code': 'InvalidParameter', 'opc-request-id': 'C1C23D2C3D22487EBD183DA8B4A27BD2', 'message': 'PREPARE: Illegal Argument: The driver or SDK being used does not support complex query.', 'operation_name': 'prepare_statement', 'timestamp': '2025-03-20T07:12:23.055327+00:00', 'client_version': 'Oracle-PythonSDK/2.149.0', 'request_endpoint': 'GET ', 'logging_tips': 'To get more info on the failing request, refer to .html for ways to log the request/response details.', 'troubleshooting_tips': "See .htm#apierrors_400__400_invalidparameter for more information about resolving this error. Also see for details on this operation's requirements. If you are unable to resolve this nosql issue, please contact Oracle support and provide them this full error message."}

Also the same error happens when I use group by, order by.

I try to write a query to nosql Oracle Cloud with statement have count like below

nosql_client = oci.nosql.NosqlClient(config)
query = """
declare 
$Key string;

SELECT count(*) FROM log_table WHERE Key = $Key
"""
Key = "HV411"

try:    
    prepare_statement_response = nosql_client.prepare_statement(
    compartment_id=compartment_ocid,
    statement = query
    )
    rows_response = nosql_client.query(
    query_details=oci.nosql.models.QueryDetails(
    compartment_id=compartment_ocid,
    is_prepared = True,
    statement=prepare_statement_response.data.statement,
    consistency="EVENTUAL",
    variables = {
    '$Key':Key,
    }
    ),
    )
    print(rows_response)
except (Exception, ValueError) as ex:
    print('Failed to execute the query ' + str(ex))

I got this error

Failed to execute the query {'target_service': 'nosql', 'status': 400, 'code': 'InvalidParameter', 'opc-request-id': 'C1C23D2C3D22487EBD183DA8B4A27BD2', 'message': 'PREPARE: Illegal Argument: The driver or SDK being used does not support complex query.', 'operation_name': 'prepare_statement', 'timestamp': '2025-03-20T07:12:23.055327+00:00', 'client_version': 'Oracle-PythonSDK/2.149.0', 'request_endpoint': 'GET https://nosql.me-jeddah-1.oci.oraclecloud/20190828/query/prepare', 'logging_tips': 'To get more info on the failing request, refer to https://docs.oracle/en-us/iaas/tools/python/latest/logging.html for ways to log the request/response details.', 'troubleshooting_tips': "See https://docs.oracle/iaas/Content/API/References/apierrors.htm#apierrors_400__400_invalidparameter for more information about resolving this error. Also see https://docs.oracle/iaas/api/#/en/nosql-database/20190828/QueryResultCollection/PrepareStatement for details on this operation's requirements. If you are unable to resolve this nosql issue, please contact Oracle support and provide them this full error message."}

Also the same error happens when I use group by, order by.

Share Improve this question edited Mar 22 at 21:59 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Mar 20 at 7:25 Elyas SalahElyas Salah 1 5
  • Binding variables is always tricky. Try removing the $Key code and hard-code the query SELECT count(*) FROM log_table WHERE Key = 'HV411'. At least get that working before trying bind variables. Also, the try/except block is unnecessary if all you are doing is printing an error to the screen. – jsf80238 Commented Mar 20 at 15:29
  • I try it, it's not work , same error – Elyas Salah Commented Mar 21 at 16:24
  • Please paste your new code in the question. Please also execute the query in some other tool to verify your SQL is valid outside Python. – jsf80238 Commented Mar 21 at 17:00
  • I was execute the query in oci console it's work – Elyas Salah Commented Mar 22 at 18:41
  • You have not posted your new code. Do that. Also, try the example at docs.oracle/en-us/iaas/tools/python-sdk-examples/2.149.0/… before you try a prepared statement. – jsf80238 Commented Mar 23 at 20:50
Add a comment  | 

1 Answer 1

Reset to default 0

There are 2 SDKs - one that we call OCI SDK and the other called NoSQL SDK.  The OCI SDKs are all built on REST and have limited query support. (more https://docs.oracle/en/cloud/paas/nosql-cloud/fkdyw/#GUID-65969D6E-6757-404D-AA58-394E12BBFB86)

That is why you have this error: The driver or SDK being used does not support complex query when using count, group by, or order by.

We recommend using our Oracle NoSQL Database Python SDK (aka Borneo) that provide complex query support and better performance.

  • https://github/oracle/nosql-python-sdk

  • https://nosql-python-sdk.readthedocs.io/en/stable/tables.html

The NoSQL Console uses NoSQL SDK behind the scenes, which is why when Elyas execute the query it's work

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论