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.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: base_dumper-0.0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa1a57654c729282584dfc138d8480670a822223a92c4d25b641b5bd320be955
MD5 d8c0bbe2019f47aee5407423a0ad3d67
BLAKE2b-256 1febc6190a0b10042ebef254bdff885925515ccb01264bde5fb2c291dd8d8f1c

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