{ "info": { "author": "Harry Li Consulting, LLC", "author_email": "hcli.consulting@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3" ], "description": "# spswarehouse\n\n# Prerequisites\n\n- Anaconda & Python 3\n- Jupyter Notebook\n\n# Installation\n\n- To install, run: `pip install spswarehouse`\n - This can be done from `Anaconda Prompt` from the Start Menu.\n- Locate the install directory by running: `pip show pip | grep \"Location:\" | cut -d \" \" -f2`\n - If this doesn't work, run `pip show pip`, then look at the line \"Location:\".\n\nThe files referred to in this `README` are in `/spswarehouse/`.\n\n## Set up dependencies\n\n- Change to the `spswarehouse` directory\n - `cd \\spswarehouse`\n - The default for Anaconda3 is `cd Anaconda3\\Lib\\site-packages\\spswarehouse`\n- Run: `pip install -r requirements.txt`\n\nYou can `exit` the Anaconda Prompt; the next step is more easily done in the File Explorer.\n\n## Set up credentials\n\nThe default directory where this module is installed is `Users\\\\Anaconda3\\Lib\\site-packages\\spswarehouse`. Your credentials are in the `spswarehouse` subdirectory.\n\n- Copy the `credentials.py.template` file to `credentials.py`.\n\n### Snowflake\n\nThis allows you to access the Snowflake data warehouse.\n\n- Fill in your Snowflake `user` and `password` credentials between quotation marks.\n\n### Google Sheets\n\nThis allows you to access your Google spreadsheets.\n\n- Get the `private_key` for the Google Service account from your team.\n- In `credentials.py`, under `google_config` and `service-account`, fill in the `private_key` between quotation marks.\n- The first time you `import` the `GoogleSheets` module, the service account's email address will be printed, you will share any spreadsheets you want to access with that email address.\n\n# Usage\n\n## Snowflake\n\nYour Snowflake connection is configured in `credentials.py` (see above).\n\nSnowflake access is implemented in by `Warehouse`. You can:\n- Read data using `read_sql()`\n- Reflect a table using `reflect_table()`\n- Run a SQL command using `execute()`\n\n### Table & column name tab-completion\n\nWhen you run `import spswarehouse`, some tab-completion for table and column names is automatically set up.\n\nThe format is:\n\n```\nspswarehouse...c_\n```\n\nTo reduce load time, tab-completion is automatically set up for only a few schemas when `spswarehouse`is imported.\n\nIf the schema you're using isn't tab-completing you can manually import it.\n\nFor example, to enable tab-competion for the schema `schoolmint`, run:\n\n```\nfrom spswarehouse.table_names import *\n\ninitialize_schema_object(SchoolMint)\nschoolmint = SchoolMint()\n```\n\n### Uploading data\n\nThe `table_utils` module implements uploading data to the Snowflake warehouse.\n\nThe data sources you can upload from are:\n\n- pandas.DataFrame `dataframe`\n- CSV file `csv_filename`\n- Google Sheet `google_sheet`\n\nThe two major methods are `create_table_stmt` and `upload_to_warehouse`. Both support the above data sources as optional arguments:\n\n - `dataframe`\n - `csv_filename`\n - `google_sheet`\n\nFrom Jupyter Notebook, open `snowflake-upload-example.ipynb` for a basic example.\n\n### Column types\n\n`create_table_stmt()` will try to guess column types when given a DataFrame, CSV file, or Google Sheet. \n\nIf you want to explicitly name and type your columns, you can pass in the `columns` argument instead.\n\nSee the documentation for `guess_col_types()` for best practices for types.\n\n## Google Sheets\n\nMake sure you've set up `credentials.py` first and shared your spreadsheet with the Google service account email. You can also get the email by running:\n\n```\nGoogleSheets.get_google_service_account_email()\n```\n\nThe Info Team service account e-mail is `jupyter-sheets@sps-warehouse.iam.gserviceaccount.com`\n\n`GoogleSheets` is really an instance of `gspread.Client`, so you use the entire\n[`gspread`](https://gspread.readthedocs.io/en/latest/) Python API.\n\n### Accessing data\n\nFrom Jupyter Notebook, open and run `googlesheets-example.ipynb` for a basic example on loading a spreadsheet and reading sheet data into `pandas.DataFrame`.\n\n### Uploading to warehouse\n\nFrom Jupyter Notebook open and run `snowflake-upload-example.ipynb` for a basic example on uploading Google Sheet data to the Snowflake warehouse.\n\n### Column types\n\n# Developer notes\n\n## Google service account key\n\nThis lets us use the Google Sheets API to access sheet data. It only has to be done once and added to `credentials.py.template`.\n\n- Use an existing Google Developer project, or create a new one: https://console.cloud.google.com\n- Enable the Google Sheets API\n - Go to **API & Services** for the project, then **Libraries**.\n - Search for \"Google Sheets\" and select the result.\n - Click **Enable**.\n- Create the OAuth client credentials\n - Go to **API & Services** for the project, then **Credentials**.\n - Under **Create credentials**, select **Service account key**\n - Choose an existing service account or create a new one to associate this key with.\n - Create the key and download the key as a JSON file.\n- Copy OAuth client credentials to `credentials.py.template` in `google_client` under `service-account`.\n- **Delete the private_key** and leave just the quotation marks when you check in `credentials.template.py`.\n- You will need to distribute the private key securely so it can be added to `credentials.py`.\n\n## PyPI\n\nWe use [PyPI](https://pypi.org/) to distribute the `spswarehouse` module and [Test PyPI](https://test.pypi.org/) for testing.\n\nThe `spswarehouse` project is [here](https://pypi.org/project/spswarehouse/).\n\n### Set up\n\nCreate PyPI and Test PyPI accounts to test and upload packages.\n\n### Packaging\n\nSee https://packaging.python.org/tutorials/packaging-projects/ for an overview and walk-through of PyPI packaging.\n\nSpecifics for `spswarehouse`:\n\n- Only build the `sdist` package. Otherwise, `credentials.py` and potentially passwords will get distributed in the binary distribution.\n- If you need to include non-Python files, add them to `MANIFEST.in`.\n\n### Testing\n\n- Update version number in `setup.py`.\n- Create the package:\n`python setup.py sdist`\n- Upload to Test PyPI:\n`python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*`\n- Install on local machine to test: `pip install -i https://test.pypi.org/simple/`\n\n### Pushing a new package\n\nMake sure all of your changes are checked into the GitHub repository and your local repository is up-to-date before you do this.\n\nThe steps are the same as in the above section, omitting the `test.pypi` URLs.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SummitPublicSchools/spswarehouse", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "spswarehouse", "package_url": "https://pypi.org/project/spswarehouse/", "platform": "", "project_url": "https://pypi.org/project/spswarehouse/", "project_urls": { "Homepage": "https://github.com/SummitPublicSchools/spswarehouse" }, "release_url": "https://pypi.org/project/spswarehouse/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Summit Public Schools Snowflake warehouse", "version": "0.0.3" }, "last_serial": 5309727, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "f4d8799045710daf5e4e3696615ff58c", "sha256": "a1fe4cbdd6e1687063cf9af44c8cae3dc2e6428c579c2239315ad16fc14a7bf8" }, "downloads": -1, "filename": "spswarehouse-0.0.1.tar.gz", "has_sig": false, "md5_digest": "f4d8799045710daf5e4e3696615ff58c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6081, "upload_time": "2019-05-03T23:46:29", "url": "https://files.pythonhosted.org/packages/bf/31/a2d69b9cfd5569f70749adcfbf2a8fb744b9c7b5ce8e4bb041383463d5fc/spswarehouse-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "aae59479259498581845cdda43a72a0d", "sha256": "a5923847489dfd5c5adb30d745de86ff4ce3984cf0db06fd2742c282cc3275df" }, "downloads": -1, "filename": "spswarehouse-0.0.2.tar.gz", "has_sig": false, "md5_digest": "aae59479259498581845cdda43a72a0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9722, "upload_time": "2019-05-23T22:20:13", "url": "https://files.pythonhosted.org/packages/2a/c3/c629c55c9d2945a18e2bdea3e184f74700ede52dd28bc61923921b827186/spswarehouse-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "d09802e5c8106c028bdad138b77ebfba", "sha256": "86694f67f639cc2afa61ca08b76d7e6dae78a2715098036dcc2d8d7d281cb5c3" }, "downloads": -1, "filename": "spswarehouse-0.0.3.tar.gz", "has_sig": false, "md5_digest": "d09802e5c8106c028bdad138b77ebfba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9726, "upload_time": "2019-05-23T22:20:14", "url": "https://files.pythonhosted.org/packages/eb/4c/55501d98f4dd9d57fd280ef6150404309e3f506cbdca0cd2097a9e698359/spswarehouse-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d09802e5c8106c028bdad138b77ebfba", "sha256": "86694f67f639cc2afa61ca08b76d7e6dae78a2715098036dcc2d8d7d281cb5c3" }, "downloads": -1, "filename": "spswarehouse-0.0.3.tar.gz", "has_sig": false, "md5_digest": "d09802e5c8106c028bdad138b77ebfba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9726, "upload_time": "2019-05-23T22:20:14", "url": "https://files.pythonhosted.org/packages/eb/4c/55501d98f4dd9d57fd280ef6150404309e3f506cbdca0cd2097a9e698359/spswarehouse-0.0.3.tar.gz" } ] }