Skip to content

Instantly share code, notes, and snippets.

@munshkr
Created July 13, 2016 14:42
Show Gist options
  • Save munshkr/94925d4a848e72788967ddef72e01cc9 to your computer and use it in GitHub Desktop.
Save munshkr/94925d4a848e72788967ddef72e01cc9 to your computer and use it in GitHub Desktop.
NewRelic Sequel test
require 'rubygems'
require 'sequel'
require 'newrelic_rpm'
# use NewRelic on DB
Sequel::Database.extension(:newrelic_instrumentation)
# connect to an in-memory database
DB = Sequel.sqlite
DB.logger = Logger.new(STDOUT)
# create an items table
DB.create_table :items do
primary_key :id
String :name
Float :price
end
# create a dataset from the items table
items = DB[:items]
# populate the table
items.insert(:name => 'abc', :price => rand * 100)
items.insert(:name => 'def', :price => rand * 100)
items.insert(:name => 'ghi', :price => rand * 100)
DB.log_yield("test sql") { "hi!" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment