Skip to main content

A toxic lil' tool to sync missing rows between two Postgres DBs.

Project description

🧠 db-shifter

_Because someone switched your fking DB URL again._**


👶 Did your intern point production to the wrong DB?

🤡 Did your devops guy swear "nothing changed" before disappearing?

🔥 Did your CTO say “just restore from backup” like you weren’t already crying?

Yeah. We’ve all been there.

Welcome to db-shifter — the little script that digs through your old PostgreSQL database and copies only the missing rows into your new one.

No overwrites. No dumbass pg_dump. Just cold, calculated migration for the chaotic neutral in you.


⚡ Why?

Because your CTO is a clown.
Because your devops team “accidentally” pointed production at the wrong motherf**king database.
Because you need to copy missing shit table-by-table and you’re too pretty to do it manually.


🧰 Features

  • ✅ Auto-detects all tables in public schema
  • ✅ Finds primary keys like a bloodhound
  • ✅ Copies only rows missing in the new DB
  • ✅ Skips duplicates (doesn’t ruin your existing data)
  • ✅ FK errors? Nah — this ain’t your grandma’s pg_dump

💾 Installation

pip install db-shifter

Or if you're a real one:

git clone https://github.com/goodness5/db-shifter.git
cd db-shifter
pip install -e .

🚀 Usage

db-shifter --old-db-url postgresql://user:pass@oldhost/db   --new-db-url postgresql://user:pass@newhost/db

🧨 Command-line options

Flag What it does
--dry-run Simulate the transfer, no data is hurt
--verbose Prints detailed logs of every row
--table users Sync just one table (you control freak)
--skip-fk Ignores foreign key errors

🧠 How It Works

  1. Connects to both DBs
  2. Lists all public tables
  3. Checks the primary key (like a snitch)
  4. Pulls rows missing from the new DB
  5. Inserts them without wrecking existing rows

⚠️ Caution

  • Assumes you have primary keys (don’t be a barbarian)
  • Does NOT handle circular FK hell — yet
  • If you’re syncing 50GB of trash, don’t cry when it lags
  • Backups are your friend. Don’t be a dumbass.

✨ Coming Soon

  • Auto topological sorting to avoid FK explosions
  • Timestamp-based syncing (created_at support)
  • GUI with a "FIX EVERYTHING" button (for product managers lol)

🪦 Contributing

Found a bug? Good.
Fix it, submit a PR, and don't drop your cashapp in the description.


📜 License

MIT. Do whatever the f**k you want. Just don’t call me if you drop prod again.

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

db_shifter-0.1.4.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

db_shifter-0.1.4-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file db_shifter-0.1.4.tar.gz.

File metadata

  • Download URL: db_shifter-0.1.4.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for db_shifter-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1bac4d72879c98f320268a4b35ed4db69b3b199d4d77df004780d473fd80ba0d
MD5 dc3e805adc0f11fa736b8a01ce0ae3fb
BLAKE2b-256 d6e3771624128670ada948903fb758b7dcc922e0e8f06cf4ade5e861cd45d5d2

See more details on using hashes here.

File details

Details for the file db_shifter-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: db_shifter-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for db_shifter-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9fefb8a77a42e3322191622c8018f3b173f9a889a35fa2af9bf38796d81ccac2
MD5 9f52a4dd25a9bbe17709df8579a80d45
BLAKE2b-256 e9a1485864b8b52eb8a6f366410c949376370c167daa28ec4b8d4ce4dc228401

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