Skip to main content

Demo library

Project description

Getting Started

A library to help create python pipelines for processing Tracer Data

Full Online Documentation

This is primarily for working with Social Media Organic and Paid Advertisement Data but also contains generic functions for writing to postgreSQL and snowflake databases, creating notifications in Slack Channels and writing to Google Sheets

Library Installation

pip install veetility

To upgrade the library after an update

pip install veetility --upgrade

Initialisation of the UtilityFunctions class

An instance of the "UtilityFunctions" class can be initiated with the ability to read/write with google sheets and also to read/write to tables in a postgreSQL database. However none of these are mandatory.

Google Sheets Authentication

In order to use the functions that read/write from google sheets then a dictionary needs to be passed to the "gspread_auth_dict" argument. This dictionary can be obtained from a google API credentials JSON file.

The instructions for creating this JSON file can be found from the gspread documentation

Then copy the JSON information in curly brackets as a python dictionary into the gspread.service_account_from_dict() authentication method. The "client_email" parameter in the JSON material is the email address of the google sheet client we have created. This email address must be given read or write access to any google sheet you want to interact with.

PostgreSQL connection parameters

The following correction parameters need to be passed in during initialisation of the class instance

  1. db_name e.g. "vayner_external_XXXXXXXXXXX"
  2. db_host e.g. "dashboard-vayner-XXXXXXXXXXXXXXXXXXXX.rds.amazonaws.com"
  3. db_port e.g. "5432" (this is the default for postgreSQL)
  4. db_user e.g. "tom.jones"
  5. db_password e.g. "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Setup in code

It is advisable to put the parameters into a config.py file (cf) which can then be imported into the main script

import config as cf
from veetility import utility_functions

util = utility_functions.UtilityFunctions(cf.google_sheet_auth_dict,cf.db_user, 
                                          cf.db_password,cf.db_host,
                                          cf.db_port, cf.db_name)

Usage in code

Once an instance of the class UtilityFunctions has been created, e.g. "util" then functions (methods) of the class can be used e.g. "write_to_gsheet()".

This can write a pandas.DataFrame to any google sheet the "client_email" has been given "editor" access to. First pass in the name of the Google Sheet workbook, then the tab of the workbook, then the pandas.DataFrame

util.write_to_gsheet("Indeed Data Error Tracking","PaidNoBoostedMatch", 
                        paid_no_boosted_match)

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

veetility-0.4.12.tar.gz (69.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

veetility-0.4.12-py3-none-any.whl (74.4 kB view details)

Uploaded Python 3

File details

Details for the file veetility-0.4.12.tar.gz.

File metadata

  • Download URL: veetility-0.4.12.tar.gz
  • Upload date:
  • Size: 69.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.17

File hashes

Hashes for veetility-0.4.12.tar.gz
Algorithm Hash digest
SHA256 0ba4b80227abf6df18b1d75991322774c6e5cde4049f7a96f14f0fa37a56ff27
MD5 75f35833cd576aa67d4dc5603b468e26
BLAKE2b-256 93a56b2a4541f2018189b4328adc3d7ffc74f10f8ddae5167a13a7c8dfb8cf0d

See more details on using hashes here.

File details

Details for the file veetility-0.4.12-py3-none-any.whl.

File metadata

  • Download URL: veetility-0.4.12-py3-none-any.whl
  • Upload date:
  • Size: 74.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.17

File hashes

Hashes for veetility-0.4.12-py3-none-any.whl
Algorithm Hash digest
SHA256 27c445a5eda31c6c2405f4b626af525d63754458fe2f6608691998fd1b3d17bb
MD5 dfa98041c16d3cd26b59d92cd59f1fd0
BLAKE2b-256 74ab4e98a3edf05acfacb4208b400ddfacff49e1156e66d056a476994057e27d

See more details on using hashes here.

Supported by

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