Skip to main content

aurora_to_rs

Lean Aurora PostgreSQL to Redshift loader using psycopg2.copy_expert + S3 + Redshift COPY.

Bypasses pandas entirely -- ~10x faster than DataFrame-based approaches for large tables. IAM role auth only.

Install

pip install aurora_to_rs

Quick Start

from aurora_to_rs import aurora_to_rs

loader = aurora_to_rs(
    region_name='ap-south-1',
    s3_bucket='my-bucket',
    redshift_c=redshift_conn,          # psycopg2 connection (autocommit=True)
    postgres_engine=pg_engine,          # SQLAlchemy engine
    iam_role_arn='arn:aws:iam::123456:role/MY_ROLE'
)

3 Strategies

1. full_load -- Full table refresh (TRUNCATE + COPY)

For master/reference tables where filter_cond = '1=1'.

loader.full_load("SELECT * FROM master.items", "master.items")

2. delete_and_insert -- Delete by filter + COPY

For transaction tables with del_table = 'Y' (incremental by date/timestamp filter).

loader.delete_and_insert(
    "SELECT * FROM tran.shipment_au WHERE create_datetime >= current_date-3",
    "tran.shipment_au",
    "create_datetime >= current_date-3",
    min_timestamp='2026-02-19',          # optional safety overlap
    timestamp_col='create_datetime'
)

3. upsert -- Staging-based incremental upsert

For tables with key-based upsert (everything else). NULL-safe key matching.

loader.upsert(
    "SELECT * FROM tran.orders WHERE dt >= current_date-1",
    "tran.orders",
    ['order_id']
)

How It Works

Aurora (PG COPY TO STDOUT)  -->  BytesIO (strip \x00, parse header)  -->  S3  -->  Redshift COPY FROM
  • Streams CSV via psycopg2.copy_expert -- no pandas DataFrame in the path
  • Strips null bytes (\x00) from Aurora text columns automatically
  • Cleans column names (/, ., - replaced with _) to match Redshift DDL
  • S3 upload with retry (exponential backoff on SSL/connection errors)
  • All methods return row_count for logging

API Reference

Method Args Returns Use Case
full_load(sql, dest) source SQL, dest table row_count Full refresh
delete_and_insert(sql, dest, filter, ...) + min_timestamp, timestamp_col row_count Incremental by date
upsert(sql, dest, keys) + upsert_columns list row_count Key-based upsert

Requirements

  • Python >= 3.8
  • boto3, psycopg2
  • IAM role with S3 read/write and Redshift COPY permissions

Metadata

Release files for aurora-to-rs 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aurora-to-rs 0.1.10
File Size Uploaded Provenance Actions
aurora_to_rs-0.1.10.tar.gz 6.3 kB Without provenance Details for aurora_to_rs-0.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aurora-to-rs 0.1.10
File Interpreter ABI Platform Actions
aurora_to_rs-0.1.10-py3-none-any.whl Python 3 none any Details for aurora_to_rs-0.1.10-py3-none-any.whl

Total release size: 13.2 kB

Release files / aurora_to_rs-0.1.10.tar.gz

Download URL aurora_to_rs-0.1.10.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
645d387478ef34bf6c7ee3fff0e2a97deffd3df6484ea9f336005b6e8b7e7c3c
BLAKE2b-256 checksum
How to use checksums
ea2ca86c60d805706fef879a27ed683cac30614374d84d3993aeb7c5c960347e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / aurora_to_rs-0.1.10-py3-none-any.whl

Download URL aurora_to_rs-0.1.10-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c11f5784701df0e02e8d71692f656f2c84be4e23f632405834c3d8146d2b54f
BLAKE2b-256 checksum
How to use checksums
333e3864f14ddb5a56c0d131c99b09b4d915564b60be315dd2b57fec2d967b01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for aurora-to-rs 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page