Metadata-Version: 2.2
Name: helpful-pys
Version: 0.2.3
Summary: A helper package to use common functions
Home-page: https://github.com/Gusto/helpful-pys
Author: Lawrence Chin
Author-email: lawrence.chin@gusto.com
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: redshift_connector>=2.1.3
Requires-Dist: pandas>=2.2.3
Requires-Dist: gspread>=6.1.3
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Helpful Helper
A (so far) little package that contains commonly used and useful functions. Good for team morale as they say.

# About
Contents include functions for connecting to redshift and using gspread, a py library for writing and reading from google sheets. For help with what functions are available, please run `get_help()` after importing helpful-pys.

[Official pypi](https://pypi.org/project/helpful-pys/)

# Installation
To install functional-functions, you can install it using pip:
````python
pip install helpful-pys
````

Within your jupyter lab/notebook setup:
````python
from helpful_pys import helper

helper.get_help()
````

## Before Using
Once the package is installed, your package will be found within your `site-packages` folder 
1. Rename your local creds file within the `helpful_pys`(rename creds.py.sample to creds.py)
3. Please authorize access to google sheets API and insert generated service account key into your local creds file, see Additional prerequisites for more details
4. Please fill in your redshift creds into the local creds file before using

# Additional Prequisites
The package will install `gspread` but will require further setup to get it running. I recommend using the [gspread documentation for Authentication](https://docs.gspread.org/en/v6.1.3/oauth2.html) which will allow you to authorize the google sheets API and generate a service account key.

Don't forget the client-email in your key, it will be constantly needed to give share access to sheets for usage with gspread.

I have included a creds.py.sample file in the package to allow the user to input their personal creds to use. If there are better access/security storage policies like AWS Secrets Manager, this repo can be updated to accommodate such.

# Usage
This package is intended for usage with local py setups and local jupyter notebook/lab setups. It is not intended for production script usage.

## Querying Redshift
````python
q = "select * from that_table limit 100"

result_df = helper.query_redshift(q)
````

## Using gspread
````python
gc = helper.gsheets_start()

workbook = gc.open_by_url('googlesheetsurlhere')

workbook.update_title("Really Cool and Helpful Workbook")

ws = test.worksheet('Sheet1')
ws.update_title("The coolest worksheet")


data_formatted = data[['id','helpful_id','cool_id']].copy()

ws.update([data_formatted.columns.values.tolist()] + data_formatted.values.tolist())
````

More [gspread example use cases](https://docs.gspread.org/en/v6.1.3/user-guide.html)
