I'm trying to write a standalone script so I can run a regular cron job that will update the database as well as cache some data to a file locally so we don't have to wait for query times. In doing so, I am using ActiveRecord. I have the following code:
require "active_record"
require "rubygems"
require "./lib/queries/my_query_file"
def my_method
#get stored query string in my_query_file
sql = MY_QUERY
@sql_con = ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:host => "my_host",
:port => "my_port",
:username => "my_user",
:password => "my_pass",
:database => "my_db",
:timeout => "100000"
)
@@query_result = @sql_con.connection.select_all(sql)
@@query_result.each do |row|
#do something
end
end
When I try to run the above script I get the following error:
Specified 'sqlserver' for database adapter, but the gem is not loaded. Add
gem ''to your Gemfile. (Gem::LoadError)
Any idea on what the issue could be? I've exhausted my search options to the point where I've gotten a headache from searching for answers. I finally caved in to post a question to see if there are any experts that help or folks that have encountered this issue before that might recall the solution.