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

Uploaded Python 3

File details

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

File metadata

  • Download URL: db_shifter-0.1.7.tar.gz
  • Upload date:
  • Size: 6.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.7.tar.gz
Algorithm Hash digest
SHA256 2245baef7dabc2df2ce5989e1a336c3fd61a2d37ee7b06b647dff356644eb6fb
MD5 bbf134bb188653ff8588d531f926ffd5
BLAKE2b-256 d457ab75776886697716322860e2dbc90edb54cd84a7445169f07c9c6465f032

See more details on using hashes here.

File details

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

File metadata

  • Download URL: db_shifter-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 7.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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b42d0525bdc3b9b8b1c7819a4bb8d3e7ae14c707dc988355c7310cbe26e28195
MD5 9c2f68e26a9a1395051d9396a34edd4e
BLAKE2b-256 5a5a6e448de4b13162fd7f704f87c410c3ef7f6b685c5bdb65895fcd17bd4bf6

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