Skip to main content

Title

summary

%load_ext autoreload
%autoreload 2

Welcome to analytics_toolbox aka atb

Enabling Data Scientists to amplify their inner Data Engineer.

A toolbox for managing data coming from multiple Postgres, Redshift & S3 data sources while performing Analytics and Research. We also have some functionality that help users build Slack Bots.

Install Us

pip install analytics_toolbox

Documentation

Our docs are currently useless as of 2020-02-12.

Vote For Change!

I'll see your comments on GitHub.

Support Us

Coming someday, maybe?

Do You Know About config Files?

analytics_toolbox is only made possible by its reliance on standardized credential storage. You wanna use us, you sadly must play by some of our rules.

We read and build classes via the variable names in the config files you pass to our code. Trust us. Its worth it. You'll end up saving 100s of lines of code by simply passing 1 to 2 arguments when instantiating our primary classes.

Config Files are a great way to store information. We chose this over other options like json or OS level environment variables for no clear reason. If you really want support for other credential formats, vote with your words here.

Config File Format Guidelines

Postgres + Redshift Connections

If your config file section has a hostname, port, database and user sections, then we'll parse it as a Redshift/Postgres database. You store your password in .pgpass (see below if this is new).

Here is an example of Postgres/Redshift entries. ""

[dev_db]
hostname = dev.yourhost.com
port = 5432
database = dbname 
user = htpeter

[prod_db]
hostname = prod.yourhost.com
port = 5432
database = dbname 
user = htpeter

What is .pgpass?

When python's psycopg2 or even psql attempt to connect to a server, they will look in a file called ~/.pgpass. If they find matching server information, based on the target they are connecting to, they use that password.

~/.pgpass's format is simple. Include a line in the file that follows the following format.

hostname:port:database:username:password

Ensure you limit the permissions on this file using chmod 600 ~/.pgpass, otherwise no tools will use it due to its insecurity.

You don't pass database passwords to analytics_toolbox. Instead we leverage pgpass. Simply paste a record for each database in a text file ~/.pgpass with the following information.

Slack Connections

Our Slack APIs use Slack Bot OAuth Tokens.

Create an OAuth token and save it to a variable called bot_user_oauth_token. You can store the token in a config section named whatever you want.

[company_slack]
oauth_token = 943f-1ji23ojf-43gjio3j4gio2-2fjoi23jfi23hio

[personal_slack]
oauth_token = 943f-dfase3-basf234234-fw4230kf230kf023k023

Usage Examples

Querying Multiple Databases & Moving Data

Our import is both useful and classy enough to be jammed up at the top with yourpds, nps and plts.

import analytics_toolbox as atb

And then you simply create a database pool object with your Config File. It loads up all the goodies.

db = atb.DBConnector('../atb_config_template.ini')

db
{   'dev_db': <analytics_toolbox.connector.DatabaseConnection object at 0x11698bc88>,
    'prod_db': <analytics_toolbox.connector.DatabaseConnection object at 0x1169d8198>}

Now we can query any of our databasese easily!

# reference with the config file keyname 
db['dev_db'].qry('select * from pg_class limit 5')
db['prod_db'].qry('select * from pg_class limit 5')

# or if config file section is pythonic, use its name just like pandas!
db.dev_db.qry('select * from pg_class limit 5')
db.prod_db.qry('select * from pg_class limit 5')

Release files for analytics-toolbox 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for analytics-toolbox 0.1.1
File Size Uploaded
analytics_toolbox-0.1.1.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for analytics-toolbox 0.1.1
File Interpreter ABI Platform
analytics_toolbox-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.6 kB

Release files / analytics_toolbox-0.1.1.tar.gz

Download URL analytics_toolbox-0.1.1.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3313644f8976df05ee1f31c590c82eb604e72f28fb19f8a373cf7f9e746aaa31
BLAKE2b-256 checksum
How to use checksums
47ea72378ad165d3540bcedb2a5cd94501738cf4d3aadc6ee02475e92c2f9b65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.10

Release files / analytics_toolbox-0.1.1-py3-none-any.whl

Download URL analytics_toolbox-0.1.1-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c315d067cfad8ef27d7155db00bff7025e7f3439bcc1d446311e0f03cfa9b3ac
BLAKE2b-256 checksum
How to use checksums
56dda5195f09045e767c0a4ed914a416d137c4ff3829ae0a11dac2a7ade6c053
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page