Skip to main content

A package containing key sp functions

Project description

Image of SportPursuit

This is the official SportPursuit Python Package

SportPursuit is the UKs first sport-specific flash sales website featuring top quality sports products and services from the world's best brands. During their 7 days flash sales, members receive exclusive access to sales at up to 70% off RRP in a fun, content rich, personalised environment.

The main site can be found here: https://www.sportpursuit.com/

Currently primarily contains functions for getting data from Redshift but will be extended in the future

Installing the package

This package can be installed using pip, e.g. pip install sportpursuit
The recommended way to call the functions is by importing sportpursuit.sportpursuit as sp then invoking the GetData class as sp.GetData.function_name()

For example a minimum set of commands to get Redshift data in a Jupyter Notebook would look like the following:
!pip install sportpursuit
import sportpursuit.sportpursuit as sp
test_sql_string = "select * from example_table limit 10;"
sp.GetData.get_redshift_data(test_sql_string)

Please note that you will have to have environment variables saved that match the form of "redshift_password" and "redshift_username" for the function to read data, or else be in a cloud environment.

Description of functions present in package

Get Secret Function

The purpose of this function is to read the cloud based credentials to enable connecting to Redshift. It takes as input what is essentially a cloud username and returns the password associated with that username. Please note, it is not necessary to run this function when attempting to read Redshift data as it is run automatically as part of that anyway. Example usage:

redshift_password = sp.GetData.get_secret("database/redshift/dataops")
redshift_username = "dataops"

Get Redshift Credentials

The purpose of this function is to read in whatever credentials are present on the system, preferentially it will use local credentials and then load cloud credentials if they are there. An error is raised if neither are present. Please note, it is not necessary to run this function when attempting to read Redshift data as it is run automatically as part of that anyway. Example usage:

redshift_username, redshift_password = sp.GetData.get_redshift_credentials()

Get Redshift Data

The purpose of this function is to take a sql query as input and return a dataframe with the results of that query. It will attempt to read in credentials automatically as part of this and will fail if none can be found. Example usage:

test_sql_string = "select * from example_table limit 10;"
sp.GetData.get_redshift_data(test_sql_string)

Execute Redshift Command

The purpose of this function is very similar to the get data function, however it differs in that it executes a command and doesn't return any data. This is used when you want to make Redshift do something internal, such as copying data into a table, or creating a new table etc. Example usage:

example_redshift_sql_command = "copy example_table from existing_table;"
sp.GetData.execute_redshift_command(example_redshift_sql_command)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sportpursuit-0.0.5-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file sportpursuit-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: sportpursuit-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.1

File hashes

Hashes for sportpursuit-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 88a34b73e6a159d1b78bb7e08da0205fd5b4c1c2ada5f70c466f0de54b276667
MD5 91d0788b7c16ec89d7698b62db9d1bd8
BLAKE2b-256 b824ab67c56a7837eee39c17bb0c2bf898288d8fe53e00f332f68b10422b9ee7

See more details on using hashes here.

Supported by

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