Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Created August 19, 2020 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanVaughan/c846a8c32ebc6d8062ef5ce468ad4e51 to your computer and use it in GitHub Desktop.
Save IanVaughan/c846a8c32ebc6d8062ef5ce468ad4e51 to your computer and use it in GitHub Desktop.
get db row counts
tables = [ "users" ]
tables.each do |table|
count = ActiveRecord::Base.connection.execute("SELECT count(*) from #{table};")
puts "#{table}, #{count.entries.first["count"]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment