The key is clearly that the AR sybase adapter depends not only on sybase
client libraries being installed, but also on the ruby sybase-ctlib
being installed. http://raa.ruby-lang.org/project/sybase-ctlib/
Kinda tricky to get that installed, but at least I know what I've got to
do now. All of this stuff is awfully underdocumented, hopefully this
thread will help someone.
If I have time soon, which, sadly, is unlikely, I will try to get this
working on an Ubuntu machine. I believe you're right, and setting up
ctlib will help you out. Let me know what works, in the end, and I'll
put that on my blog as well - because you're right, this is very sadly
underdocumented.
If I have time soon, which, sadly, is unlikely, I will try to get this
working on an Ubuntu machine. I believe you're right, and setting up
ctlib will help you out. Let me know what works, in the end, and I'll
put that on my blog as well - because you're right, this is very sadly
underdocumented.
I _think_ I've got ctlib properly compiled (against freetds rather than
Sybase's own libraries, no less). but I can't figure out where to PUT
the products of the compile. the ctlib readme says:
" Please copy sybct.o sybct.so sybct.rb sybsql.rb to somewhere of
$LOAD_PATH."
I am not sure what that means. Can't figure out where to put those files
where a Rails app will find them, and << require 'sybsql' >> (a line in
the AR adapter) won't just say "no such file to load".
Any ideas?
It's odd that sybase ctlib isn't simply a gem in the first place. That
would be a real service, if you wanted to make it into a gem. Although
compiling it is still going to require some manual attention to the
extconf.rb file depending on where your sybase client libraries are.
I am not sure what that means. Can't figure out where to put those files
where a Rails app will find them, and << require 'sybsql' >> (a line in
the AR adapter) won't just say "no such file to load".
Any ideas?
Mine are in C:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt
You probably have some i686 or i386 or i686-gcc directory there, instead
of msvcrt.
It's odd that sybase ctlib isn't simply a gem in the first place. That
would be a real service, if you wanted to make it into a gem. Although
compiling it is still going to require some manual attention to the
extconf.rb file depending on where your sybase client libraries are.
Yeah.. I suppose I -could- try that, but I'm just a dumb SA/DBA who
tries to go above and beyond the call of duty. The idea crossed my mind
before, maybe I do know just enough Ruby to get in trouble with that
now.
Okay, I figured out my problem with the help of "ruby -e 'puts $:'". I
had a number of site_ruby directories that LOOKED legit, but weren't
actually in the load path, who knows.
But it's STILL not actually working. So, no, Aldric, I can't show you in
a simple ruby program how I'm connecting, because it's still not
working, heh.
But to get CLOSE to working, I had to:
1) Install the OpenTds libraries
2) Install the ruby sybase-ct libraries. That was the tricky part, and I
_think_ they're properly installed now.
3) Then we go into to "gem install active-record-sybase-adapter", yes.
And your ActiveRecord::Base.establish_connection example.
Which for me, STILL, even now that I'm pretty sure I have ruby sybase-ct
installed properly, just says:
ActiveRecord::Base.establish_connection(:adapter => 'sybase')
RuntimeError: Please install the sybase adapter: `gem install
activerecord-sybase-adapter` (no such file to load --
active_record/connection_adapters/sybase_adapter)
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in
`establish_connection'
And, yes, I have the gem installed. Beleive it or not, before I had the
gem installed, it was a DIFFERENT error.
I have no firewall in the way. Don't know if the software didn't compile
right or what. Sigh.
Geez, it may be that the ruby sybase-ctlib oddly seems to have NO
facility for specifying what port to connect to Sybase on? I think my
Sybase might be on a non-standard port, 2025. I think the port isn't
making it into the attempt to connect.
How could this have been left out? Man oh man. Maybe I'm
misinterpreting. But looking at the code in ruby sybase-ctlib, and can't
find any way to specify a port -- which would give the ActiveRecord
sybase connector know way to pass on the port info.
I have no firewall in the way. Don't know if the software didn't compile
right or what. Sigh.
Geez, it may be that the ruby sybase-ctlib oddly seems to have NO
facility for specifying what port to connect to Sybase on? I think my
Sybase might be on a non-standard port, 2025. I think the port isn't
making it into the attempt to connect.
How could this have been left out? Man oh man. Maybe I'm
misinterpreting. But looking at the code in ruby sybase-ctlib, and can't
find any way to specify a port -- which would give the ActiveRecord
sybase connector know way to pass on the port info.
Did you see how my original tutorial involves editing an SQL.ini file ?
Can you try that?
Did you see how my original tutorial involves editing an SQL.ini file ?
Can you try that?
Thanks, I believe that is indeed the key, and would work. But the
complexity of getting this working (Two different compiled packages,
confusing configuration, needing to configure connections outside of the
ruby app itself, etc) is making me re-think my whole approach to
accessing my legacy Sybase database.
Jonathan
You would most likely want to transfer all the data to a mySQL or
PostgreSQL database (possibly renaming the id fields to railsify the
whole thing) and then not touch the Sybase DB again.
Maybe get a Windows box or VM, just long enough to do what you want
(30-day trial for Windows) ?
My new plan (not really related to this thread, but perhaps useful for
someone thinking about these things) is to write a web service in Java
(there is already plenty of java code to talk to this db) that provides
just the information needed by my ruby app (not actually the entirety of
the database, not even close, just a few pieces of info, almost entirely
read-only, for a few specific use cases) -- and just have the ruby app
consume the web service instead.
Good luck! Sorry you spent so much time on this. Maybe I -will- try to
develop some kind of gem for this, but don't hold me to it.. It's low on
my list of priorities, and I don't have the skills required to just put
it all together.