Utility library for python
Project description
Tracktolib
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 testing
- 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
Built Distribution
Hashes for tracktolib-0.48.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a62c5ba5c99b642986f7a92bd447011510c0e0b7c4a041ab080bf457a8bff00b |
|
MD5 | f085a5bc94b39432438e3923d726d7ae |
|
BLAKE2b-256 | e496176d5b8ba9fbf5f03b7a5292d687c26a275557283e93557f4a284e82ca95 |