A package to upload Pandas DataFrame to Redshift
Project description
df_to_rs
df_to_rs
is a Python package that provides convenient methods to upload and upsert Pandas DataFrames to Amazon Redshift.
Installation
Install the package using pip:
pip install df_to_rs
Usage
Initialization
from df_to_rs import df_to_rs
import psycopg2
uploader = df_to_rs(
region_name='ap-south-1',
s3_bucket='your-s3-bucket',
aws_access_key_id='your-access-key-id',
aws_secret_access_key='your-secret-access-key',
redshift_c=psycopg2.connect(dbname='more', host="hostname.ap-south-1.redshift.amazonaws.com", port=1433, user='username', password='password')
)
Upload DataFrame to Redshift
uploader.upload_to_redshift(df, dest='analytics.ship_pen')
Upsert DataFrame to Redshift
Upsert (insert or update) the DataFrame into a specified destination table in Redshift. Matching rows are identified by the specified columns, and existing rows are deleted before new rows are inserted.
uploader.upsert_to_redshift(df, dest_table='analytics.ship_pen', upsert_columns=['id', 'name'])
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
df_to_rs-0.1.14.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for df_to_rs-0.1.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19fe1db3535096a23bc1668246837b65c55e61fab6bbc07bef14e114bd08f42b |
|
MD5 | 566db8a3ca9d1df6a7e9279dbca3414a |
|
BLAKE2b-256 | e93605ced72c7a4f30a7cb23269ccd8321c7f39e062f1c1b06d7becff1f29a77 |