|
|
|
|
|
by hmage
1938 days ago
|
|
#!/usr/bin/env bash
WANTMODE=wal
for file in "$@"; do
MODE=`sqlite3 -init <(echo .timeout 10000) -batch "$file" 'PRAGMA journal_mode;'`
if [[ $MODE == $WANTMODE ]]; then continue; fi
OLDSIZE=`du -kc "$file" "$file-wal" "$file-shm" 2>/dev/null | tail -n1 | cut -f1`
echo -n "$file: "
echo "PRAGMA journal_mode=$WANTMODE;" | sqlite3 -init <(echo .timeout 10000) -batch "$file"
if [[ $? != 0 ]]; then continue; fi
NEWSIZE=`du -kc "$file" "$file-wal" "$file-shm" 2>/dev/null | tail -n1 | cut -f1`
echo "${OLDSIZE}kb -> ${NEWSIZE}kb"
done
|
|