Metadata-Version: 2.1
Name: pandashift
Version: 1.0.2
Summary: Module for quick and easy access to redshift using pandas
Author-email: Maksim Linichenko <maksim.linichenko@yahoo.com>
Project-URL: Homepage, https://github.com/tumax7/pandashift
Project-URL: Issues, https://github.com/tumax7/pandashift/issues
Keywords: redshift,pandas,analytics,amazon
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: psycopg
Requires-Dist: psycopg[binary]
Requires-Dist: pandas

# pandashift
Wrapper for working with Amazon Redshift using pandas without the use of S3

## Installing

``` shell
pip install pandashift
```

## Usage
There are 2 ways work with this package

1. Setting up environment variables 
2. Passing credentials on every call

Below are examples of both approaches

### With environment variables set up

``` python
from pandashift import read_query, execute_query, load_db

# Read Data
df = read_query('SELECT * FROM public.test')

# Execute statement (aka table create/drop/etc)
execute_query('TRUNCATE public.test')

# Loading dataframe
load_df(df, table_name ='public.test')
```

### No environment variables
``` python
from pandashift import read_query, execute_query, load_db

creds = {
        "host":"YOUR HOST",
        "port":"YOUR PORT",
        "dbname":"YOUR DATABASE",
        "user":"YOUR USER",
        "password":"YOUR PASSWORD"
        }

# Read Data
df = read_query('SELECT * FROM public.test',credentials = creds)

# Execute statement (aka table create/drop/etc)
execute_query('TRUNCATE public.test',credentials = creds)

# Loading dataframe
load_df(df, table_name = 'public.test',credentials = creds)
```

## Functions

### load_df

| Parameter             | Usage                                                                                                                           |
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------|
| init_df               | The dataframe for loading                                                                                                       |
| table_name            | The table that you want to load the df to                                                                                       |
| credentials           | Credentials to use for connection if any                                                                                        |
| verify_column_names   | The checks that the dataframe column order matches the table column order, by default **True**                                  |
| empty_str_as_null     | This option will interpret empty string '' as NULL, by default  **True**                                                        |
| maximum_insert_length | Maximum length of the insert statement, alter this if you get error exceeding the max statement length, by default **16000000** |
| perform_analyze       | If this is true at the end of loading will run ANALYZE table, by default  **False**                                             |
