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.5.tar.gz (5.5 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.5-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for db_shifter-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f655e71145e905865e156ba1f3fdb6c10e0b231ca84cc6bf0eff76afe6a0f4fa
MD5 45f1bcd905c211ceb0c5194fe3a52a5f
BLAKE2b-256 00f0904baf3fafc44e84407aabd57149435ed7800c0f15068d647d06bd878e05

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for db_shifter-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9671b5d9abd150e89f29f1aa0f427ef52670c887a8bd64ad971c238e86ee437b
MD5 c8e62005408492eea30d1e9b6e23c988
BLAKE2b-256 81b3fd93c4701be559d15e2ee1acbdab97847f0d1af9de4fd474d2754537d15a

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