Skip to main content

PYthon COmmon Functions

Project description

PYCOF (PYthon COmmon Functions)

1. Installation

Downloads PyPI version

You can get pycof from PyPI with:

pip install pycof

The library is supported on Windows, Linux and MacOs.

2. Usage

2.1. Documentation

You can find the full documentation at https://www.florianfelice.com/pycof or by clicking on the name of each function in the next section. It will redirect you the the function's specific documentation.

2.1. Available functions

The current version of the library provides:

  • remote_execute_sql: aggragated function for SQL queries to SELECT, INSERT, DELETE or COPY.
  • read: Load any data file, regarless of the format.
  • send_email: simple function to send email to contacts in a concise way.
  • verbose_display: extended function to print strings, lists, data frames and progression bar if used as a wrapper in for loops.
  • add_zero: simple function to convert int to str by adding a 0 is less than 10.
  • group: will convert an int to a str with thousand seperator.
  • replace_zero: will transform 0 values to - for display purposes.
  • week_sunday: will return week number of last sunday date of a given date.
  • display_name: displays the current user name. Will display either first, last or full name.
  • write: writes a str to a specific file (usually .txt) in one line of code.
  • file_age: computes the age (in days, hours, ...) of a given local file.
  • str2bool: converts string to boolean.
  • And many others!

2.2. Config file for credentials

The function remote_execute_sql and send_email will by default look for the credentials located at /etc/.pycof/config.json. On Windows, save the config file as C:/Windows/.pycof/config.json.

The file follows the below structure:

{
	"DB_USER": "",
	"DB_PASSWORD": "",
	"DB_HOST": "",
	"DB_PORT": "3306",
	"DB_DATABASE": "",
	"__COMMENT_1__": "Email specific, send_email"
	"EMAIL_USER": "",
	"EMAIL_PASSWORD": "",
	"EMAIL_SMTP": "smtp.gmail.com",
	"EMAIL_PORT": "587"
	"__COMMENT_2__": "IAM specific, if useIAM=True in remote_execute_sql",
	"CLUSTER_NAME": "",
	"AWS_ACCESS_KEY_ID": "",
	"AWS_SECRET_ACCESS_KEY": "",
	"REGION": "eu-west-1"
}

On Unix based system, run:

sudo nano /etc/.pycof/config.json

and paste the above json after filling the empty strings (pre-filled values are standard default values).

Reminder: To save the file, with nano press CTRL + O, confirm with y then CTRL + X to exit.

On Windows, use the path C:/Windows/.pycof/config.json.

Project details


Release history Release notifications | RSS feed

This version

1.8.0

Download files

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

Source Distribution

pycof-1.8.0.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

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

pycof-1.8.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file pycof-1.8.0.tar.gz.

File metadata

  • Download URL: pycof-1.8.0.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycof-1.8.0.tar.gz
Algorithm Hash digest
SHA256 3e9106a246c4a533a100c460ee405a94252a6e061409f1df41badc98d53ec157
MD5 891eddd4ede89db78a37e420872a1d89
BLAKE2b-256 e3eb0d2fec1e597df1cb5fc9cd95d042ae97c673da10e945b1d4a9dbdd1e8945

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycof-1.8.0.tar.gz:

Publisher: release.yml on florianfelice/PYCOF

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycof-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: pycof-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycof-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fcf8273efd9165c45e9d5bf0775b852f1921cf741e61a0afa9d41d46836ec5f2
MD5 68a1ffbcbca1405c6f0f880ef5f94e4f
BLAKE2b-256 5b432395d211eceddccf82e0493ed626cd33ccae7de2f718d9e855ff3289be39

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycof-1.8.0-py3-none-any.whl:

Publisher: release.yml on florianfelice/PYCOF

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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