Thanks for this, Jeremy! I tried building and installing the tinytds gem, but I 
don't have much experience with locally built gems and something went awry. 
I'll revisit that in a few days and watch for the 0.4 version and switch to 
that. 

In the meantime, I've built and installed the ruby-odbc gem along with iODBC 
and the OpenLink SQL Server drivers which seems to have helped as I no longer 
get a Seg Fault when I access our databases. I can successfully connect and 
query the db through ruby-odbc. 

However, when I try to use sequel, I'm getting an "Incorrect syntax near '1'" 
error.  Here's the call stack:
Sequel::DatabaseError: ODBC::Error: S1000 (102) [OpenLink][ODBC][Express 
Edition]Incorrect syntax near '1'.
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:51:in
 `run'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:51:in
 `block (2 levels) in execute'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/database/logging.rb:28:in
 `log_yield'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:51:in
 `block in execute'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:84:in
 `hold'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/database/connecting.rb:226:in
 `synchronize'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:49:in
 `execute'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:541:in
 `execute'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:91:in
 `fetch_rows'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:123:in
 `each'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:449:in
 `single_record'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:457:in
 `single_value'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:202:in
 `get'
        from 
/Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:96:in
 `count'
        from (irb):4
        from /Users/andyt/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'

The code that I've executed when I get that is
DB = Sequel.odbc('{my DSN name}', :user => '{my user}', :password = '{my 
password}', :dbtype => 'mssql')
ds = DB[:glb_people]
ds.count

Is this also a case where I should just switch to tiny tds, or is there 
something else going on here?

Thanks!

Andy


-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Jeremy Evans
Sent: Friday, March 04, 2011 2:38 PM
To: sequel-talk
Subject: Re: Seg fault when accessing SQL Server

On Mar 4, 12:13 pm, Andy Tinkham <[email protected]> wrote:
> I'm trying to get database access set up on my mac book pro for some 
> automated tests. I've created an ODBC connection (tried using both 
> Open Link's iODBC and actual technologies' sql server driver - both 
> were the free versions since I wanted o get one working before paying 
> for it), which claims to be set up successfully when I click the Test 
> button in the DSN setup wizard.  I've got ruby 1.9.2-p180, sequel 
> 3.21.0, and I'm trying to connect to a db on an MS SQL Server 2005 
> server.  I'm using irb for the moment to work out the correct syntax.

With 3.21.0, you are much better off using the new tinytds adapter instead of 
ODBC.  The only issue with this is that you currently need to build a tiny_tds 
gem from the git master branch and install it.
When tiny_tds releases version 0.4.0, this will no longer be necessary.  With 
tiny_tds, you only need to install freetds and configure freetds.conf, then use 
the freetds.conf section name as your
host: tinytds://user:pass@host/database

Alternatively, you could use JRuby and the JDBC adapter with the JTDS driver.

> In irb, I can create the database object. To verify things worked, I 
> tried to run DB[:glb_People].count. When I do that (or when I have a 
> data set from that table that I try to get the count of), I get a 
> segmentation fault. I've put the details of the seg fault 
> athttps://gist.github.com/855619
>
> I see at the end of the seg fault that this might be a bug in Ruby.
> Does anyone have any ideas for things I can look at to confirm if this 
> is the case, or to figure out what if anything I'm doing wrong?

Sequel is pure ruby code, so if anything you are doing in Sequel segfaults, the 
bug is either in the interpreter or in a C extension library.  In this case, it 
is most likely in the odbc extension.

Jeremy

--
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to