I'm not on Windows and I don't use SQL server, but ActiveRecord has an
adapter for MS SQL Server, try something like:
gem install activerecord activerecord-sqlserver-adapter
irb --simple-prompt
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:host => ".\\SQLEXPRESS",
:database => "YourDB",
:username => "me",
:password => "topSekrit"
)
ActiveRecord::Base.pluralize_table_names = false # if your tables are not
following AR's conventions
class Purchase < ActiveRecord::Base
set_table_name 'msft_purchases' # only if your table names have nothing to
do with the class name
end
Purchase.first
You can also use http://sequel.rubyforge.org/ which is awesome (lower level)
ORM supporting MS SQL Server.
- Matt
On Mon, Feb 15, 2010 at 8:48 PM, Greg Willits <[email protected]> wrote:
> I'm a Mac guy, but I need to write some Ruby (not Rails) that will run on a
> variety of Windows systems connected to a variety of SQL Server versions
> (probably just 2005 and 2008).
>
> I have VMWare Fusion, Windows XP (and Vista), Ruby 1.9.1, and SQL Server
> 2008 Express all installed. After a few hours of hair pulling, I managed to
> get SQL Server Express installed and a simple db/table created with a couple
> dummy records.
>
> Now, I need to figure out how to get at that data using bare Ruby so I can
> create a generic SQLServer adaptor (MySQL one works just fine) for my code.
>
> I'm surprised (sort of) at how little info there is for this.
>
> I have fiddled with these two techniques for some time with no joy.
> http://snippets.dzone.com/posts/show/3906 *
> http://waysysweb.com/qa/odbc.html
>
> * this would be my preferred way as it is much simpler, and I have to help
> dozens & dozens of half-skilled school district IT employees to implement
> this.
>
> Compared to MySQL, SQL Server seems really convoluted to me, and I'm
> drowning in MS's circular online help systems (not to mention the
> eyestrain-inducing layouts).
>
> Is there anyone here that has a similar dev setup (WinXP, Ruby 1.9,
> SQLServer Express) that can be my Q&A email buddy to get this figured out.
> If it turns out to be lengthy, I'll gladly pay for your time.
>
> --
> def gw
> lives_at 'www.gregwillits.ws'
> end
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby