Skip to main content

Lean Aurora PostgreSQL to Redshift loader via copy_expert + S3 COPY

Project description

aurora_to_rs

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

~10x faster than DataFrame-based approaches for large tables (bypasses pandas entirely).

Install

pip install aurora_to_rs

Usage

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
    postgres_engine=pg_engine,          # SQLAlchemy engine
    iam_role_arn='arn:aws:iam::123:role/MY_ROLE'
)

# Full table refresh (TRUNCATE + COPY)
loader.upsert("SELECT * FROM master.items", "master.items", ['item_id'], clear_dest_table=True)

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

# Delete and insert
loader.delete_and_insert(
    "SELECT * FROM tran.shipment WHERE dt>=current_date-3",
    "tran.shipment", "dt>=current_date-3",
    min_timestamp='2026-02-19', timestamp_col='dt'
)

# Direct copy (no delete)
loader.copy_expert_upload("SELECT * FROM staging.temp", "staging.temp")

Methods

Method Use Case
copy_expert_upload Direct Aurora -> S3 -> Redshift COPY
delete_and_insert DELETE by filter, then COPY new data
upsert TRUNCATE+COPY (clear_dest_table=True) or staging-based upsert

Project details


Download files

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

Source Distribution

aurora_to_rs-0.1.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

aurora_to_rs-0.1.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file aurora_to_rs-0.1.2.tar.gz.

File metadata

  • Download URL: aurora_to_rs-0.1.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for aurora_to_rs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 249f342e1e15548ae3c5e49a285ea7cba4680744bf014f580338276a91616dd9
MD5 9110cdb2d35379e990800cf3916345ac
BLAKE2b-256 6f3e370cf26218296428542d23632f33e7abf516caf334c46a22d06e7d748ae2

See more details on using hashes here.

File details

Details for the file aurora_to_rs-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aurora_to_rs-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for aurora_to_rs-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e0eff9b48b15c3e1687c33fdb0cba2dd13f4be46ff9b6cade89e6150c8e3ab4
MD5 ba09e3d3ada7b6e2900a72a7d9d28774
BLAKE2b-256 b7ee7ff333ec378128750b42a9f90d4aaddd7e48e788f29f8136a7c9e3bda592

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