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
--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.6.tar.gz (5.6 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.6-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for db_shifter-0.1.6.tar.gz
Algorithm Hash digest
SHA256 5c231c24ca5002764fc41dd22e78e55e3b91f165e79b1f75f3604b042d4bf4a3
MD5 fce204bbe21979fac0f51e98fbbd9b4c
BLAKE2b-256 5403eb9189aa9d7c5eb48b9a8970874dedad8790c0732e9c9cfb6ea417feecfc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for db_shifter-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1598b59580331932a581bdf412929b2aee971f8ad87600d578a8597f6ba629dc
MD5 08a7596b4760b89fbcb81a269f196c12
BLAKE2b-256 62ffb8b28513876b6ef7e0c534d516997e8871905c4a0fb33aa14129442746e5

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