Skip to content

Instantly share code, notes, and snippets.

@IanVaughan

IanVaughan/db rows

Created Aug 19, 2020
Embed
What would you like to do?
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