Created
March 14, 2009 17:39
-
-
Save hgmnz/79129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Using Fedora Core 9) | |
http://wiki.rubyonrails.org/database-support/ms-sql | |
sudo yum install unixODBC.x86_64 unixODBC-devel.x86_64 | |
sudo yum install freetds.x86_64 freetds-devel.x86_64 | |
sudo gem install dbd-odbc | |
sudo gem install dbi | |
sudo gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org | |
In /etc/freetds.conf | |
[server_def] | |
host = server_ip_address | |
port = 1433 | |
tds version = 8.0 | |
client charset = UTF-8 | |
In /etc/odbc.ini | |
[server_def] | |
Driver = FreeTDS | |
Description = ODBC connection via FreeTDS | |
Trace = No | |
Servername = server_def | |
Database = server_db | |
In /etc/odbcinst.ini | |
[FreeTDS] | |
Description = TDS driver (Sybase/MS SQL) | |
Driver = /usr/lib64/libtdsodbc.so | |
Setup = /usr/lib64/libtdsS.so | |
CPTimeout = | |
CPReuse = | |
FileUsage = 1 | |
TDS Should be set up fine: | |
tsql -S server -U user -P password | |
In production.log, I get this error: | |
DBI::InterfaceError (Unable to load driver 'ODBC' (underlying error: uninitialized constant DBI::DBD::ODBC)) | |
Solution was to install ruby-odbc: | |
RubyODBC: | |
wget http://ch-werner.de/rubyodbc/ruby-odbc-0.9996.tar.gz | |
tar -xvzpf ruby-odbc-0.9996.tar.gz | |
cd ruby-odbc-0.9996 | |
ruby extconf.rb | |
make | |
sudo make install | |
But now, you'll get this error: | |
DBI::DatabaseError (IM002 (0) [unixODBC][Driver Manager]Data source name not found, and no default driver specified) | |
/usr/lib64/ruby/gems/1.8/gems/dbd-odbc-0.2.4/lib/dbd/odbc/driver.rb:36:in `connect' | |
/usr/lib64/ruby/gems/1.8/gems/dbi-0.4.1/lib/dbi/handles/driver.rb:33:in `connect' | |
/usr/lib64/ruby/gems/1.8/gems/dbi-0.4.1/lib/dbi.rb:142:in `connect' | |
/usr/lib64/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-1.0.0.9250/lib/active_record/connection_adapters/sqlserver_adapter.rb | |
:47:in `sqlserver_connection' | |
This happens to be a problem with the data source. To test this directly: | |
isql -v datasource username password | |
[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified | |
[ISQL]ERROR: Could not SQLConnect | |
I've also tried symlinking both config files to /usr/local/etc: | |
sudo ln -s /etc/odbc.ini /usr/local/etc/odbc.ini | |
sudo ln -s /etc/odbcinst.ini /usr/local/etc/odbcinst.ini | |
Might be helpful to use dltest => The Driver=xxx entry points to a shared object which does not export the necessary ODBC API functions (you can test this with dltest included with unixODBC) |
yeah, but so long ago I don't remember at all.
Actually I seem to remember paying for some driver, I think it was $40, and all worked.
@will because I don't know if you get notified
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you end up solving this?