Skip to content

Instantly share code, notes, and snippets.

@rgorsuch
Created February 4, 2017 16:02
Show Gist options
  • Save rgorsuch/6c23eba279d94e1012fe87164ad59348 to your computer and use it in GitHub Desktop.
Save rgorsuch/6c23eba279d94e1012fe87164ad59348 to your computer and use it in GitHub Desktop.
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