Here is the code:
client = TinyTds::Client.new username: 'sa', password: 'secret', host: 'mydb.host.net, database: MYDB, dataserver: MYDS'
I want to test the connection and report if it is alive or not:
if client.active?
puts "Connection to #{client.database} on #{client.dataserver} is alive"
else
puts "Unable to establish connection to #{client.database} on #{client.dataserver}"
end
Here is the error:
<main>': undefined method `database' for #<TinyTds::Client:0x007f8b9384d840> (NoMethodError)
If client is an object, how do I access database
and dataserver
?
It doesn't look to me like you can. tiny_tds is pretty low-level, and has a very basic API. Consider using sequel as a higher-level database access layer that will give you a more convenient API to work with. Sequel can use tiny_tds to access appropriate databases.