Skip to content

botocore.errorfactory AWS TimeStream

0

I am getting the following error when I try to query my table in AWS TSDB using Python: botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the Query operation: The query syntax is invalid at line 3:18 This is the piece of code I run based on https://github.com/awslabs/amazon-timestream-tools/blob/mainline/sample_apps/python/QueryExample.py import boto3 from botocore.config import Config session = boto3.Session()

query_client = session.client('timestream-query')

DATABASE_NAME = "test" TABLE_NAME = "test_table"

class Query(object):

def __init__(self, client):
    self.client = client
    self.paginator = client.get_paginator('query')

def run_query(self, query_string):
    try:
        page_iterator = self.paginator.paginate(QueryString=query_string)
        for page in page_iterator:
            self._parse_query_result(page)
    except Exception as err:
        print("Exception while running query:", err)

query = Query(query_client)

QUERY_1 = f""" SELECT plant, edgedevice, measure_value::double FROM {DATABASE_NAME}.{TABLE_NAME} LIMIT 10 """ query_output = query.run_query(QUERY_1)

asked 3 years ago812 views
1 Answer
0
Accepted Answer

The problem was in the way the query was written. I solved by putting quotations before and after the curly brackets QUERY_1 = f""" SELECT plant, edgedevice, measure_value::double FROM "{DATABASE_NAME}"."{TABLE_NAME}" LIMIT 10 """ query_output = query.run_query(QUERY_1)

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.