Skip to main content

Utility library for python

Project description

Tracktolib

Python versions Latest PyPI version CircleCI

Utility library for python

Installation

You can choose to not install all the dependencies by specifying the extra parameter such as:

poetry add tracktolib@latest -E pg-sync -E tests --group dev 

Here we only install the utilities using psycopg (pg-sync) and deepdiff (tests) for the dev environment.

Utilities

  • log

Utility functions for logging.

import logging
from tracktolib.logs import init_logging

logger = logging.getLogger()
formatter, stream_handler = init_logging(logger, 'json', version='0.0.1')
  • pg

Utility functions for asyncpg

  • pg-sync

Utility functions based on psycopg such as fetch_one, insert_many, fetch_count ...

To use the functions, create a Connection using psycopg: conn = psycopg2.connect()

fetch_one

from pg.pg_sync import (
    insert_many, fetch_one, fetch_count, fetch_all
)

data = [
    {'foo': 'bar', 'value': 1},
    {'foo': 'baz', 'value': 2}
]
insert_many(conn, 'public.test', data)  # Will insert the 2 dict
query = 'SELECT foo from public.test order by value asc'
value = fetch_one(conn, query, required=True)  # Will return {'foo': 'bar'}, raise an error is not found
assert fetch_count(conn, 'public.test') == 2
query = 'SELECT * from public.test order by value asc'
assert fetch_all(conn, query) == data
  • tests

Utility functions for tests such as get_uuid (that generates a test uuid based on an integer)

get_uuid

from tracktolib.tests import get_uuid

assert get_uuid(1) == '00000000-0000-0000-0000-000000000001'
  • s3-minio

Utility functions for minio

  • s3

Utility functions for aiobotocore

  • logs

Utility functions to initialize the logging formatting and streams

  • http

Utility functions using httpx

  • api

Utility functions using fastapi

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

tracktolib-0.23.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

tracktolib-0.23.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file tracktolib-0.23.1.tar.gz.

File metadata

  • Download URL: tracktolib-0.23.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1021-aws

File hashes

Hashes for tracktolib-0.23.1.tar.gz
Algorithm Hash digest
SHA256 dcf4e4b5cf7bee0f2d986ee43a5f2f52059701fb38721e38bfa7d7b17206e5a4
MD5 295cb410210f3c598d549404420ad3b0
BLAKE2b-256 9679e64e64137ff057adcc3c6011538880666c5fe0e6a254adf9c759e0318308

See more details on using hashes here.

File details

Details for the file tracktolib-0.23.1-py3-none-any.whl.

File metadata

  • Download URL: tracktolib-0.23.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1021-aws

File hashes

Hashes for tracktolib-0.23.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f74c653a8eb4a0e847a2f5179a4c7ee9c6c227819e5606ae882556a5e9c1cf3
MD5 1513331ab81842e26dbb5516d6161efc
BLAKE2b-256 5ef0b76ae103ed89a0b5ed5592bc207c5efea4184e6f5296d4011f458fceab22

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