Using SQLite-manager (in its XUL form) on a Mac.
How can I diff a SQLite file from one submitted by someone else on the team, and incorporate his changes?
Thanks.
I believe you could use the following, in combination:
$ diff sqlite-file-1.sql sqlite-file-2.sql > sqlite-patch.diff
$ patch -p0 sqlite-file-1.sql sqlite-patch.diff
I hope that works for you. Otherwise, I highly suggest consulting the man-pages:
$ man diff
$ man patch
EDIT: Alright, here's the whole walk-through.
First, dump the databases:
$ sqlite test1.sql .dump > test1.sql.txt
$ sqlite test2.sql .dump > test2.sql.txt
Next, generate a diff file:
$ diff -u test1.sql.txt test2.sql.txt > patch-0.1.diff
And, finally, to apply the patch:
$ patch -p0 test1.sql.txt patch-0.1.diff
We can use the sqldiff Utility Program:
https://www.sqlite.org/sqldiff.html
It will compare the source to the destination databases and generate SQL commands to make source equivalent to destination.
- Any differences in the content of paired rows are output as UPDATEs.
- Rows in the source database that could not be paired are output as DELETEs.
- Rows in the destination database that could not be paired are output as INSERTs.
We have to download the sources and compile it, from the tool folder.
Maybe using this tool: http://download.cnet.com/SQLite-Diff/3000-10254_4-10894771.html ? But you can use the solution provided by @indienick provided you first dump the binary sqlite database with something like: sqlite x.db .dump > output.sql
Hope this helps, Moszi
来源:https://stackoverflow.com/questions/4580368/how-can-i-diff-2-sqlite-files