Metadata-Version: 2.4
Name: base_dumper
Version: 0.0.0.3
Summary: Abstract class and base common modules for dbhose-airflow dumpers.
Author-email: 0xMihalich <bayanmobile87@gmail.com>
License: MIT License
        
        Copyright (c) 2025 0xMihalich
        
        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/0xMihalich/base_dumper
Project-URL: Documentation, https://0xmihalich.github.io/dbhose_airflow/classes/base_dumper/index.html
Project-URL: Repository, https://github.com/0xMihalich/base_dumper
Project-URL: Changelog, https://github.com/0xMihalich/base_dumper/blob/main/CHANGELOG.md
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
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
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: README.md
License-File: CHANGELOG.md
Requires-Dist: light-compressor==0.0.2.2
Requires-Dist: sqlparse==0.5.4
Requires-Dist: pandas
Requires-Dist: polars
Dynamic: license-file

# Base Dumper

Abstract base classes and common utilities for database dumpers in the `dbhose-airflow` ecosystem.

## Overview

`base_dumper` provides the foundation for building database dumpers with consistent interfaces for reading,

writing, and transferring data between different database systems.

It includes abstract classes, common data structures, and utility functions.

## Features

- **Abstract Base Classes**: `BaseDumper`, `AbstractCursor`, `AbstractReader`
- **Multi-query Support**: Automatic splitting and execution of multiple SQL statements
- **Data Format Support**: Convert between database tables and Python, pandas, or polars
- **Streaming**: Memory-efficient data transfer between sources
- **Transaction Management**: Configurable isolation levels
- **Logging**: Built-in logging with file and console output
- **Compression**: Integration with `light_compressor` for compressed dumps

## Installation

```bash
pip install base-dumper
```

## Core Components

### BaseDumper

Abstract dumper class that all database-specific dumpers should inherit from.

```python
from base_dumper import BaseDumper, DBConnector, CompressionMethod, IsolationLevel

class PostgreSQLDumper(BaseDumper):
    # Implement abstract methods
    pass
```

### Data Transfer Methods

- **read_dump**: Read data from source to file
- **write_dump**: Write data from file to destination
- **write_between**: Transfer directly between databases
- **to_reader**: Get data as stream object
- **from_rows/pandas/polars**: Write from Python data structures

### Utilities

- **chunk_query**: Split multi-query strings into individual statements
- **transfer_diagram**: Generate visual representation of data transfer
- **random_name**: Generate random names for temporary objects
- **DBConnector**: Database connection parameters container

## Usage Example

```python
from base_dumper import DBConnector, CompressionMethod

# Create connector
connector = DBConnector(
    host="localhost",
    dbname="mydb",
    user="user",
    password="pass",
    port=5432
)

# Initialize dumper (with concrete implementation)
dumper = PostgreSQLDumper(
    connector=connector,
    compression_method=CompressionMethod.ZSTD,
    isolation=IsolationLevel.committed
)

# Read dump to file
with open("dump.sql.zst", "wb") as f:
    dumper.read_dump(f, table_name="users")

# Convert to pandas DataFrame
reader = dumper.to_reader(table_name="users")
df = reader.to_pandas()
```

## Requirements

* Python >= 3.10
* light-compressor
* sqlparse
* pandas
* polars
