Metadata-Version: 2.1
Name: df_to_rs
Version: 0.1.5
Summary: A package to upload Pandas DataFrame to Redshift
Home-page: https://github.com/ankitgoel888/df_to_rs
Author: Ankit Goel
Author-email: ankitgoel888@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6, <4
Description-Content-Type: text/markdown
License-File: LICENSE.txt


# 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:

```bash
pip install df_to_rs
```

## Usage

### Initialization

```python
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

```python
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.

```python
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](LICENSE.txt) file for details.
