4 ms·
Sqldiff: SQLite Database Difference Utility
- drothlis 5y agoMentioned in yesterday's discussion on declarative schema migrations for SQLite: https://news.ycombinator.com/item?id=31249823 https://news.ycombinator.com/item?id=31249823
- Jleagle 5y agohttps://xkcd.com/927/ https://xkcd.com/927/
- nbevans 5y agoWhat is the relevance of this to SQLite's diff tool?
- mch82 5y agoI don’t get the XKCD reference either. It’s the opposite. There are many ways to diff database schemas but, as I understand the doc, this utility actually compares the data stored in a database with the data stored in another database having the same schema. I’m not aware of any other “built-in” tools for comparing the content of databases.
- hobs 5y agoThere's a bunch of them out there and they mostly suck. https://docs.microsoft.com/en-us/sql/ssdt/how-to-compare-and-synchronize-the-data-of-two-databases?view=sql-server-ver15 https://docs.microsoft.com/en-us/sql/ssdt/how-to-compare-and... https://www.red-gate.com/products/sql-development/sql-data-compare/ https://www.red-gate.com/products/sql-development/sql-data-c... https://www.apexsql.com/sql-tools-datadiff.aspx https://www.apexsql.com/sql-tools-datadiff.aspx
- merijnv 5y agoIt actually also compares data when the two databases have different schemas! It's pretty nice for quickly comparing changes in datasets.
- Jleagle 5y agoOops commented on the wrong post! If a mode sees, please delete.
- mixcocam 5y agoCool debugging tool when updating databases which pull data from various sources!
- dewey 5y agoI was debugging Postgres permissions the other day and was hoping for a tool where you can just diff the permissions of a table between databases and see why in one database a certain user has permissions (to insert, execute,...) and in the other one it doesn't. That might be a naive ask and maybe that's not even possible but I'm wondering if such a thing exists?
- gregplaysguitar 5y agoCheck out migra[1] - it covers most of that. One notable omission is column-level grants though - as far as I know changes to those aren’t detected [1] https://github.com/djrobstep/migra https://github.com/djrobstep/migra
- dewey 5y agoThis looks interesting, thanks for sharing! I'll give it a try. Do you by any chance know if it detects different search paths too between roles? (That was my actual issue in the end while debugging why role A could execute a function and role B couldn't).
- e12e 5y agoThanks for mentioning migra. Unfortunately it looks like it's only for identical databases - ie using public schema - so it can't diff dba.user1_schema.table1 vs dbb.user2_schema.table1? I don't have any production DBs that use public/not-instance/user-specific schemas :/
- michelpp 5y agoI am not very familiar with this tool, and the documentation doesn't mention this use case but it does look like you can pass specific schema(s) or exclude them: https://github.com/djrobstep/migra/blob/master/migra/migra.py#L15 https://github.com/djrobstep/migra/blob/master/migra/migra.p... It looks like the schema do have to have the same name between the databases, which I think is sensible but again I could be wrong. This is a darker corner of the postgres tooling world that could definitely use some light, so good on the migra devs to trying this out. If you do get it working, consider sending them a PR with some documentation on your use case!
- euroderf 5y agoFYI FWIW: brew install sqldiff
- westurner 5y agoWhich {SQL,} databases do this as a native, online database feature; so you don't have to pull backups to sqldiff? E.g. django-reversion and VDM do versioned domain model on top of SQL, but not with native temporal database features. Many apps probably could or should be written as mostly-append-only - not necessarily blocking until the previous record is available to hash – but very few apps are written that way, so run sqldiff offline.
- skybrian 5y agoThere is Dolt, which started out as git for tables but is turning into a MySQL compatible database with good versioning. (Including branches and merges.)
- westurner 5y agodolthub/dolt https://github.com/dolthub/dolt https://github.com/dolthub/dolt: dolt clone dolt pull dolt push dolt checkout dolt branch dolt commit dolt merge dolt blame dolt diff mgramin/awesome-db-tools > schema > changes: https://github.com/mgramin/awesome-db-tools#changes https://github.com/mgramin/awesome-db-tools#changes EthicalML/awesome-production-machine-learning#model-and-data-versioning: https://github.com/EthicalML/awesome-production-machine-learning#model-and-data-versioning https://github.com/EthicalML/awesome-production-machine-lear...
- jonnycomputer 5y agoOn mac, you can install with macports: sudo port install sqlite3-tools If you use brew (and you shouldn't), then brew install sqldiff
- mrfusion 5y agoI’ve always wanted a diff for query results to know if anything changes when I’m optimizing a query.
- hichkaker 5y agoWe actually built a tool exactly for that: https://www.datafold.com/data-diff https://www.datafold.com/data-diff The core use case is helping data engineers building analytical pipelines test the changes to their code prior to deploying, but can also work for any query. You can diff tables or just SQL queries directly.
- thedougd 5y agoThis could be very useful for working on applications that store configuration in SQLite databases.
- yencabulator 5y agoSee also https://github.com/simonw/sqlite-diffable https://github.com/simonw/sqlite-diffable for output that's easier to machine process.