The quickest way to get data from SQL to excel in python
- bdata3
- Dec 7, 2019
- 1 min read
Updated: Dec 9, 2019
So....
We'll try to give useful ideas, tips and peace of codes for you (and us) to explore and use.
in this case the quickest way to get data to excel out of a database.
will take AWS Athena but any database will do.
from pyathena import connect
import pandas as pd
conn = connect(aws_access_key_id=user,aws_secret_access_key=key,s3_staging_dir='s3://staging/s1/',region_name='eu-west-1')
df=pd.read_sql_query('select * from demo_table limit 200',conn)
df.to_excel('~/demo_table.xlsx',index=False)

Comments