I need the Rails application to connect to the MS SQL Server database and make a simple search query. The main database for the application is MySQL. It just needs to do this thing SQL Server on the side.
What is the best way to do this?
I could write a completely separate Java application that connects to the database and uploads some XML data to the file system for my Ruby application.
Or I could team up with a Ruby ODBC connection. I did a search in the Gemcutter and found them ...
- dbd-odbc (0.2.5) 11141 downloads
- ruby-odbc (0.99992) 6390 downloads
- activeerecord-odbc-adapter (2.0) 2333 download
- odbc-rails (1.5) 2167 downloads
This would mean connecting to two different databases from the same Rails application. I don’t even know how to do this.
- SQL Server Ruby? , ?
UPDATE -
. , . . . .
, SQL Server Ruby OS X
, , FreeTDS
, . , .
/usr/local/freetds/lib.
. .
, : " tsql FreeTDS ".
/etc/profile:
PATH=$PATH:/usr/local/freetds/bin
export PATH
FreeTDS
FreeTDS. , . , , ~/.freetds.conf...
[DATA_SERVER_NAME]
host = hostname
port = 1433
tds version = 8.0
. [DATA_SERVER_NAME] , . . Ruby- tiny_tds gem.
ODBC
, FreeTDS, odbc.ini odbcinst.ini. .
tiny_tds
tiny_tds Ruby FreeTDS SQL Server. tiny_tds ...
'... , FreeTDS libiconv , . "tsql -C" "iconv library: yes". '
, .
:
require 'tiny_tds'
client = TinyTds::Client.new(:username => '...username...', :password => '...password...', :dataserver => 'DATA_SERVER_NAME')
sql = '... whatever ...'
result = client.execute(sql)
client.close
ActiveRecord
ActiveRecord SQL Server , , , activerecord-sqlserver-adapter. , .