On Tuesday, 10 Jul 2018 2:27 PM -0400, Randall Smith wrote:
<snip>
> My underlying question is "can text-comparing two DB dumps be used
> to determine what has changed?"
I don't know if it will meet your needs, but I've written a script for
my own purposes to compare DB changes. Since it's fairly short, I
include it here.
--8<---------------cut here---------------start------------->8---
#!/bin/sh
# Compare two SQLite3 databases.
# If invoked under the name "tksql3diff", the diff is displayed graphically
# using tkdiff to display the differences.
#
# Last modified: 10-Jul-2018 Wm. Parsons
if [ $# -ne 2 ]
then
echo "Usage: `basename $0` <filename1> <filename2>"
exit
fi
if [ `basename $0` = "tksql3diff" ]
then
diff=tkdiff
else
diff=diff
fi
file1=$1
file2=$2
dump()
{
file=$1
# check that the file is readable
if [ ! -r $file ]
then
echo "cannot read $file" >&2
exit 1
fi
sql="select 'Application ID:'; pragma application_id;
select 'User version:'; pragma user_version;"
tables=`sqlite3 $file <<EOF
select name from sqlite_master where type='table' order by name;
EOF
`
for t in $tables
do
sql="$sql select '$t:'; select * from $t;"
done
echo "$sql" | sqlite3 $file > $file.dump
}
dump $file1
dump $file2
$diff $file1.dump $file2.dump
rm $file1.dump $file2.dump
--8<---------------cut here---------------end--------------->8---
Note: This *probably* doesn't play well if you have BLOB fields in
your database.
--
Will
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users