def run_query(ENDPOINT,KEY, unix_timestamp,token,container_name):
client = CosmosClient(url=ENDPOINT, credential=KEY)
database = client.get_database_client(database_name)
container = database.get_container_client(container_name)
general_query = "SELECT * FROM @container_name c WHERE c.RowKey>'@RowKey'"
parameters = [
{"name": "@PartitionKey", "value": str(token)},
{"name": "@RowKey", "value": int(unix_timestamp)},
{"name": "@database_name", "value": str(database_name)},
{"name": "@container_name", "value": str(container_name)}
]
for param in parameters:
general_query = general_query.replace(param['name'], str(param['value']))
items_tmp = list(container.query_items(query=general_query,
partition_key=token # specifying the partition key
))
return len(items_tmp)>0
the following python method works in case the
general_query = "SELECT * FROM @container_name c"
the moment any where condition like this is inserted
general_query = "SELECT * FROM @container_name c WHERE c.RowKey>'@RowKey'"
it doesn't work.
(I even tried >'0', which covers all cases and it doesn't work)
(I also tried >0, without quotes and it doesn't work)
WHERE c.RowKey > @RowKeycontainerobject. You're making things more complicated than it needs to be - justSELECT * FROM c WHERE...will work@container_namename as parameter, you don't need to provide@database_nameor@PartitionKey. And aside from all that, you really should edit your question to provide a minimal reproducible example, including some sample data, as well as exact query (not showing the substitution strings), expected vs actual results, errors, etc. Right now it's too ambiguous.