Metadata-Version: 2.4
Name: analytics-toolkit
Version: 1.3.6.12
Summary: Shared Python utilities for SQL, Excel, and date helpers.
Author: analytics_toolkit contributors
License: MIT License
        
        Copyright (c) 2026 analytics_toolkit contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/Karapsin/analytics_toolkit
Project-URL: Source, https://github.com/Karapsin/analytics_toolkit
Project-URL: Issues, https://github.com/Karapsin/analytics_toolkit/issues
Keywords: analytics,ab-testing,sql,excel,airflow
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Database
Classifier: Topic :: Office/Business
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: <3.15,>=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: clickhouse-connect<1,>=0.5.14
Requires-Dist: lz4<5,>=4.3.2
Requires-Dist: numpy<2,>=1.24.2
Requires-Dist: openpyxl<4,>=3.1.1
Requires-Dist: orjson<4,>=3.8.7
Requires-Dist: pandas<3,>=1.4.4
Requires-Dist: psycopg2-binary<3,>=2.9.5
Requires-Dist: python-dateutil<3,>=2.8.2
Requires-Dist: pytz>=2022.7
Requires-Dist: requests<3,>=2.28.2
Requires-Dist: scipy<2,>=1.10.1
Requires-Dist: sqlglot<31,>=20
Requires-Dist: sqlparse<1,>=0.4.3
Requires-Dist: tqdm<5,>=4.65.0
Requires-Dist: trino<1,>=0.320
Requires-Dist: zstandard<1,>=0.20.0
Provides-Extra: airflow
Requires-Dist: apache-airflow<3,>=2.4; extra == "airflow"
Dynamic: license-file

# analytics_toolkit

`analytics_toolkit` is a small utility package for:

- AB-test related helpers
- SQL I/O and table-loading helpers for Trino, Greenplum, and ClickHouse
- date helpers for common period calculations
- Excel helpers for writing pivoted tables from long-format data

## Install

From PyPI:

```bash
pip install analytics-toolkit
```

From GitHub:

```bash
pip install git+https://github.com/Karapsin/analytics_toolkit.git
```

## Release

PyPI publishing uses GitHub Actions trusted publishing. Before each release,
run the full local tox matrix from `AGENTS.md`, update the changelog, and verify
the package build:

```bash
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
```

Run the `publish` workflow manually to publish the current version to TestPyPI.
After the TestPyPI install check passes, create and publish a GitHub release
tagged as `v<pyproject.toml version>`; the release event publishes to PyPI.
The PyPI trusted publisher uses repository `Karapsin/analytics_toolkit`,
workflow `.github/workflows/publish.yml`, and environment `pypi`. The TestPyPI
trusted publisher uses the same repository and workflow with environment
`testpypi`.

## Quick Start

```python
from analytics_toolkit.ab_utils import compute_test_metrics
from analytics_toolkit import sql
from analytics_toolkit.dates.dates import first_day
from analytics_toolkit.excel import break_table, pivot_and_break_table
```

Supported SQL imports are `from analytics_toolkit import sql` or
`import analytics_toolkit.sql as sql`. Deep imports under
`analytics_toolkit.sql.*` are internal implementation details and may change;
call SQL helpers through the `sql` facade, for example `sql.create_sql_table(...)`
or `sql.transfer(...)`. Do not restore removed root implementation paths.

## Configuration

SQL connection settings are read from `.connections`. The package searches
from the current working directory upward through parent directories. Each key is
the public connection alias used by `analytics_toolkit.sql`; each value must
include `type` as one of `gp`, `trino`, or `ch`.

```json
{
  "gp": {
    "type": "gp",
    "host": "gp.example",
    "port": 5432,
    "user": "user",
    "password": "password",
    "database": "db"
  },
  "gp_sandbox": {
    "type": "gp",
    "host": "gp-sandbox.example",
    "user": "user",
    "password": "password",
    "database": "sandbox"
  }
}
```

Legacy variables such as `GP_HOST`, `TRINO_HOST`, `CH_HOST`, `SQL_CONNECTIONS`,
and `TRINO_INSERT_CHUNK_SIZE` are not read. Move connection settings into
`.connections`; Trino insert chunk sizing is the Trino connection field
`insert_chunk_size`.

If a Trino connection sets `use_keychain_certs=true`, the generated CA bundle is
written to:

- `<connections_file_directory>/certs/trino-<connection-key>-keychain-ca.pem`

You can override the state/output directory with `MAGNIT_UTILS_HOME`.

## Manuals

- [analytics_toolkit Manual](manuals/ANALYTICS_TOOLKIT_MANUAL.md)
- [Airflow SQL Manual](manuals/AIRFLOW_SQL_MANUAL.md)

## Package Layout

- `analytics_toolkit/ab_utils`: AB-test metric comparison helpers, including `compute_test_metrics`
- `analytics_toolkit/dates`: date and period helpers
- `analytics_toolkit/excel`: Excel formatting helpers
- `analytics_toolkit/sql`: SQL execution, loading, and transfer helpers
