tracktolib


Nametracktolib JSON
Version 0.47.1 PyPI version JSON
download
home_pagehttps://github.com/tracktor/tracktolib
SummaryUtility library for python
upload_time2024-03-17 15:41:56
maintainer
docs_urlNone
authorJulien Brayere
requires_python>=3.10,<4.0
licenseMIT
keywords utility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tracktolib

[![Python versions](https://img.shields.io/pypi/pyversions/tracktolib)](https://pypi.python.org/pypi/tracktolib)
[![Latest PyPI version](https://img.shields.io/pypi/v/tracktolib?logo=pypi)](https://pypi.python.org/pypi/tracktolib)
[![CircleCI](https://circleci.com/gh/Tracktor/tracktolib/tree/master.svg?style=shield)](https://app.circleci.com/pipelines/github/Tracktor/tracktolib?branch=master)

Utility library for python

# Installation

You can choose to not install all the dependencies by specifying
the [extra](https://python-poetry.org/docs/cli/#options-4) parameter such as:

```bash
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.

```python
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](https://github.com/MagicStack/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*

```python
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](https://min.io/docs/minio/linux/developers/python/API.html)

- **s3**

Utility functions for [aiobotocore](https://github.com/aio-libs/aiobotocore)

- **logs**

Utility functions to initialize the logging formatting and streams

- **http**

Utility functions using [httpx](https://www.python-httpx.org/)

- **api**

Utility functions using [fastapi](https://fastapi.tiangolo.com/)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tracktor/tracktolib",
    "name": "tracktolib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "utility",
    "author": "Julien Brayere",
    "author_email": "julien.brayere@tracktor.fr",
    "download_url": "https://files.pythonhosted.org/packages/91/3e/1fde17e260d0e4ab9281cf5d79842264a8a60fedca50ce838f89879be7df/tracktolib-0.47.1.tar.gz",
    "platform": null,
    "description": "# Tracktolib\n\n[![Python versions](https://img.shields.io/pypi/pyversions/tracktolib)](https://pypi.python.org/pypi/tracktolib)\n[![Latest PyPI version](https://img.shields.io/pypi/v/tracktolib?logo=pypi)](https://pypi.python.org/pypi/tracktolib)\n[![CircleCI](https://circleci.com/gh/Tracktor/tracktolib/tree/master.svg?style=shield)](https://app.circleci.com/pipelines/github/Tracktor/tracktolib?branch=master)\n\nUtility library for python\n\n# Installation\n\nYou can choose to not install all the dependencies by specifying\nthe [extra](https://python-poetry.org/docs/cli/#options-4) parameter such as:\n\n```bash\npoetry add tracktolib@latest -E pg-sync -E tests --group dev \n```\n\nHere we only install the utilities using `psycopg` (pg-sync) and `deepdiff` (tests) for the dev environment.\n\n# Utilities\n\n- **log**\n\nUtility functions for logging.\n\n```python\nimport logging\nfrom tracktolib.logs import init_logging\n\nlogger = logging.getLogger()\nformatter, stream_handler = init_logging(logger, 'json', version='0.0.1')\n```\n\n- **pg**\n\nUtility functions for [asyncpg](https://github.com/MagicStack/asyncpg)\n\n- **pg-sync**\n\nUtility functions based on psycopg such as `fetch_one`, `insert_many`, `fetch_count` ...\n\nTo use the functions, create a `Connection` using psycopg: `conn = psycopg2.connect()`\n\n*fetch_one*\n\n```python\nfrom pg.pg_sync import (\n    insert_many, fetch_one, fetch_count, fetch_all\n)\n\ndata = [\n    {'foo': 'bar', 'value': 1},\n    {'foo': 'baz', 'value': 2}\n]\ninsert_many(conn, 'public.test', data)  # Will insert the 2 dict\nquery = 'SELECT foo from public.test order by value asc'\nvalue = fetch_one(conn, query, required=True)  # Will return {'foo': 'bar'}, raise an error is not found\nassert fetch_count(conn, 'public.test') == 2\nquery = 'SELECT * from public.test order by value asc'\nassert fetch_all(conn, query) == data\n\n```\n\n- **tests**\n\nUtility functions for testing\n\n- **s3-minio**\n\nUtility functions for [minio](https://min.io/docs/minio/linux/developers/python/API.html)\n\n- **s3**\n\nUtility functions for [aiobotocore](https://github.com/aio-libs/aiobotocore)\n\n- **logs**\n\nUtility functions to initialize the logging formatting and streams\n\n- **http**\n\nUtility functions using [httpx](https://www.python-httpx.org/)\n\n- **api**\n\nUtility functions using [fastapi](https://fastapi.tiangolo.com/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Utility library for python",
    "version": "0.47.1",
    "project_urls": {
        "Homepage": "https://github.com/tracktor/tracktolib",
        "Repository": "https://github.com/tracktor/tracktolib"
    },
    "split_keywords": [
        "utility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "458df31e62632e25b9dfd176e14969cbfaa50435b694ee3cb5953ab36679156a",
                "md5": "c7c4809eea7cfa6462c2654b61c4ce6f",
                "sha256": "8f5bc4aa48a5848824dffef760c49b7eeb6afca61da4f6a2caf7940e4e1f41da"
            },
            "downloads": -1,
            "filename": "tracktolib-0.47.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c7c4809eea7cfa6462c2654b61c4ce6f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 21640,
            "upload_time": "2024-03-17T15:41:54",
            "upload_time_iso_8601": "2024-03-17T15:41:54.506305Z",
            "url": "https://files.pythonhosted.org/packages/45/8d/f31e62632e25b9dfd176e14969cbfaa50435b694ee3cb5953ab36679156a/tracktolib-0.47.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "913e1fde17e260d0e4ab9281cf5d79842264a8a60fedca50ce838f89879be7df",
                "md5": "6aed66042ccde4dd5e46ca4af30dcbc0",
                "sha256": "386c56a79dd1ff65940c15606e822c26ea5c52be3c1025af79d82557d49120b5"
            },
            "downloads": -1,
            "filename": "tracktolib-0.47.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6aed66042ccde4dd5e46ca4af30dcbc0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 18634,
            "upload_time": "2024-03-17T15:41:56",
            "upload_time_iso_8601": "2024-03-17T15:41:56.743984Z",
            "url": "https://files.pythonhosted.org/packages/91/3e/1fde17e260d0e4ab9281cf5d79842264a8a60fedca50ce838f89879be7df/tracktolib-0.47.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-17 15:41:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tracktor",
    "github_project": "tracktolib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "lcname": "tracktolib"
}
        
Elapsed time: 0.20599s