How to Create Dataframe from AWS Athena using Boto3 get_query_results method

前端 未结 5 2174
广开言路
广开言路 2021-02-13 05:37

I\'m using AWS Athena to query raw data from S3. Since Athena writes the query output into S3 output bucket I used to do:

df = pd.read_csv(OutputLocation)
         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-13 06:19

    Maybe you can try to use pandas read_sql and pyathena:

    from pyathena import connect
    import pandas as pd
    
    conn = connect(s3_staging_dir='s3://bucket/folder',region_name='region')
    df = pd.read_sql('select * from database.table', conn) #don't change the "database.table"
    

提交回复
热议问题