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
.
1 Answer
Reset to default 0There 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
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