Skip to main content

Abstract class and base common modules for dbhose-airflow dumpers.

Project description

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

pip install base-dumper

Core Components

BaseDumper

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

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

base_dumper-0.0.0.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file base_dumper-0.0.0.2-py3-none-any.whl.

File metadata

  • Download URL: base_dumper-0.0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for base_dumper-0.0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0cde3b8ccd0454849cb092995cce9561b39244041c0b802ee5b1c0f4e5fda6a1
MD5 abc75377fea7003180ffb0cc6c065563
BLAKE2b-256 b8f2bcd14da15a9e162c5170c4a278780bad9ead4ff5b505f5ab4fb61b8af401

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