How to write data to Redshift that is a result of a dataframe created in Python?

后端 未结 6 846
谎友^
谎友^ 2020-12-14 08:27

I have a dataframe in Python. Can I write this data to Redshift as a new table? I have successfully created a db connection to Redshift and am able to execute simple sql que

6条回答
  •  春和景丽
    2020-12-14 08:42

    import pandas_redshift as pr
    
    pr.connect_to_redshift(dbname = ,
                            host = ,
                            port = ,
                            user = ,
                            password = )
    
    pr.connect_to_s3(aws_access_key_id = ,
                    aws_secret_access_key = ,
                    bucket = ,
                    subdirectory = )
    
    # Write the DataFrame to S3 and then to redshift
    pr.pandas_to_redshift(data_frame = data_frame,
                            redshift_table_name = 'gawronski.nba_shots_log')
    

    Details: https://github.com/agawronski/pandas_redshift

提交回复
热议问题