Created
February 4, 2017 16:02
-
-
Save rgorsuch/6c23eba279d94e1012fe87164ad59348 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function count_rows { | |
# Count the rows in all the tables in a sqlite db | |
# Usage: count_rows my-sqlite.db | |
DB=$1 | |
TABLES=`echo "SELECT name FROM sqlite_master WHERE type='table';" | sqlite3 $DB` | |
for TABLE in $TABLES | |
do | |
printf "%10d %s\n" `echo "SELECT count(*) from $TABLE;" | sqlite3 $DB` $TABLE | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment