Forum: Ruby on Rails using isql from rails app

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
54dc7abacbcee71d157666b1f737d28b?d=identicon&s=25 anitawa (Guest)
on 2007-05-03 23:59
(Received via mailing list)

Im new to rails and was wondering if someone can help me.
I have a sybase database on a remote machine.

I want to get information from that db into my rails app using isql.

I can do it from the shell, but how do i do it from a rails app?

thanks in advance
Bc6c0fd7296921fb7eae416f7c9e86a1?d=identicon&s=25 David Richards (Guest)
on 2007-05-04 00:31
(Received via mailing list)
Hmmm, I don't know anything about isql, but two possibilities stand

If this is a once-in-a-while administrative task, you could create a
rake task (I really like this tutorial for that:

On the other hand, you could create a script in lib and bootstrap
rails to it.  The template code I've been using to get the rails
environment ready is:

#!/usr/bin/env ruby

# Ensure the environment was specified
if ARGV.length != 1
  puts "usage: ruby file_name.rb <rails_env>"
  exit 1

$LOAD_PATH << File.expand_path(File.dirname(__FILE__))


require File.dirname(__FILE__) + '/../config/boot'
require "#{RAILS_ROOT}/config/environment"

def connect(environment)
  conf = YAML::load( + '/../config/

# Open ActiveRecord connection

At this point, you've got Rails running.  You'll want to have included
any libraries necessary to use isql.  Then, you're just writing ruby
code between isql and rails.

Good luck.

David Richards
Bc6c0fd7296921fb7eae416f7c9e86a1?d=identicon&s=25 David Richards (Guest)
on 2007-05-04 00:41
(Received via mailing list)
Oh, btw, I forgot to mention.  If you take the second approach--a lib/
file_name.rb approach to this, you'd just dump that in your crontab
and call it regularly.

If you needed to just access your information at runtime through
rails, you'd put something in environment.rb to tell rails how to
access isql, but then you'd be on your own for actually doing
something with that connection.

Hope this helps,

David Richards
This topic is locked and can not be replied to.