[Python] how to save lambda result on elastic search [fechada]

Discussão em 'Python' iniciado por Stack, Setembro 13, 2021.

  1. Stack

    Stack Membro Participativo

    import json
    import boto3
    import time

    tbepbira = 'data' #tabela que pegarei no athena


    def lambda_handler(event, context):
    client = boto3.client('athena')
    print('1 - até aqui tudo certo')
    inicioQuery = client.start_query_execution(
    QueryString = 'SELECT Item.bira_id.S as bira_id FROM ' + tbepbira + ' LIMIT 10',
    QueryExecutionContext = {
    'Database': 'bira_teste'
    },
    ResultConfiguration = {
    'OutputLocation': 's3://bira/teste_athena/resultado_query/'
    }
    )

    queryId = inicioQuery['QueryExecutionId'] ## salva no S3 o result
    print('2 - até aqui tudo certo')
    time.sleep(15)

    results = client.get_query_results(QueryExecutionId = queryId)
    for row in results['ResultSet']['Rows']:
    print(row)


    return {
    'statusCode': 200,
    'body': json.dumps('Hello from Lambda!')
    }

    Continue reading...

Compartilhe esta Página