Skip to main content

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


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.21.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

df_to_rs-0.1.21-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file df_to_rs-0.1.21.tar.gz.

File metadata

  • Download URL: df_to_rs-0.1.21.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for df_to_rs-0.1.21.tar.gz
Algorithm Hash digest
SHA256 7a7fabbe6992f17dd9872d433b86c761707f2d4c41b6396fa6c0c066d216c77e
MD5 2c8c9ffb4ce9f39e19460b078e0208ea
BLAKE2b-256 2b6518255566f9161036ab38008c49ad74e1402496db7bb5d3e84e194e585ec9

See more details on using hashes here.

File details

Details for the file df_to_rs-0.1.21-py3-none-any.whl.

File metadata

  • Download URL: df_to_rs-0.1.21-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for df_to_rs-0.1.21-py3-none-any.whl
Algorithm Hash digest
SHA256 363f2ffc7c37d4904b8471ad99ea1a7d6330fb070cadc33d1a0d9240d1bc0cb4
MD5 16ad085f1a4d8084671f6dc132eb293b
BLAKE2b-256 f19a6c3abbb5d5a49af303f6b023ab8b26079390c16710d89c481fd1260b9642

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page