Skip to content

Instantly share code, notes, and snippets.

@aaronbbrown
Created August 17, 2012 16:58
Show Gist options
  • Save aaronbbrown/3380582 to your computer and use it in GitHub Desktop.
Save aaronbbrown/3380582 to your computer and use it in GitHub Desktop.
count queries
#!/usr/bin/env ruby
require 'pp'
h = { :select => 0, :insert => 0, :delete => 0, :update => 0}
ARGF.each do |line|
case line
when /SELECT.*FROM/i then
h[:select] += 1
when /INSERT.*INTO/i then
h[:insert] += 1
when /DELETE.*FROM/i then
h[:delete] += 1
when /UPDATE.*SET/i then
h[:update] += 1
end
end
pp h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment