ODBC error message do not contain any details

14 views
Skip to first unread message

Yoni Eilon

unread,
Jul 7, 2021, 9:10:59 AMJul 7
to sequel-talk
We use Sequel to query Snowflake from Ruby code using the ruby-odbc gem.

When there is a problem with the query in Snowflake, we don't get back an understandable error from the Sequel, but just a general ODBC error, with something that looks like an  SQLSTATE code. 

For example, when I run this query on Snowflake, trying to query a non existent table named "bla":
res = conn.fetch("select * from bla").all

I get back this error:
Sequel::DatabaseError (ODBC::Error: 4 (2003) S)

Instead of:
"Object 'BLA' does not exist or not authorized"

We're using:
Sequel gem - 5.38.0
ruby-odbc gem - version 0.99999
Snowflake ODBC driver - version 2.21.6
Ruby - version 2.6.6

Any help would be highly appreciated.

Yoni.

Jeremy Evans

unread,
Jul 7, 2021, 11:05:07 AMJul 7
to seque...@googlegroups.com
I'm guessing you get that error because the ODBC driver uses "4 (2003) S" as the exception message.  Not much Sequel can do in this case.  If you want this fixed, you'll probably need to fix the ODBC driver.

Thanks,
Jeremy

Yoni Eilon

unread,
Aug 3, 2021, 7:47:05 AMAug 3
to sequel-talk
Hi,

I'm still trying to solve this issue... Now I'm trying to use iODBC Manager driver (libiodbc) instead of unixODBC.

However, when I try to use Sequel.connect with the "driver" parameter receiving the path to the Snowflake driver (/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib on MacOS), I get this error:
IM003 [iODBC][Driver Manager]Specified driver could not be loaded

Does Sequel work with other ODBC drivers on MacOS, such as libidobc, or only with unixODBC?

Thanks,
Yoni.

Jeremy Evans

unread,
Aug 3, 2021, 10:40:36 AMAug 3
to seque...@googlegroups.com
On Tue, Aug 3, 2021 at 4:47 AM Yoni Eilon <yoni....@riskified.com> wrote:
Hi,

I'm still trying to solve this issue... Now I'm trying to use iODBC Manager driver (libiodbc) instead of unixODBC.

However, when I try to use Sequel.connect with the "driver" parameter receiving the path to the Snowflake driver (/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib on MacOS), I get this error:
IM003 [iODBC][Driver Manager]Specified driver could not be loaded

Does Sequel work with other ODBC drivers on MacOS, such as libidobc, or only with unixODBC?

Sequel's odbc adapter should work in any case where the underlying ruby odbc driver works.  If you can get a connection using the ruby odbc driver, then you should also be able to get Sequel's odbc adapter to work.  If you cannot get a connection using the ruby odbc adapter, there is no way that Sequel's odbc adapter will work.  As to the question of whether the ruby odbc driver supports libidobc or unixODBC, you would have to ask the developers of the ruby odbc driver.

Thanks,
Jeremy

Yoni Eilon

unread,
Aug 9, 2021, 3:56:08 PMAug 9
to sequel-talk
Hi Jeremy,

Thanks for the reply, still trying to check I'm able to connect using the Ruby ODBC driver.

In the mean time, I tried to connect using "Sequel.odbc" method instead of "Sequel.connect", like this:
db = Sequel.odbc('SnowflakeDSII', user: 'XXXX, password: 'YYYYY')

And this does work... Any idea why this works and "connect" doesn't? 
Needless to say the DSN I point to in the ".odbc" method is the same as the one I pass as the "driver" parameter of the "connect" method (in this case, it's the path to Snowflake's ODBC driver on Mac: /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib)
 
Thanks,
Yoni.

Jeremy Evans

unread,
Aug 9, 2021, 4:17:09 PMAug 9
to seque...@googlegroups.com
On Mon, Aug 9, 2021 at 12:56 PM Yoni Eilon <yoni....@riskified.com> wrote:
Hi Jeremy,

Thanks for the reply, still trying to check I'm able to connect using the Ruby ODBC driver.

In the mean time, I tried to connect using "Sequel.odbc" method instead of "Sequel.connect", like this:
db = Sequel.odbc('SnowflakeDSII', user: 'XXXX, password: 'YYYYY')

And this does work... Any idea why this works and "connect" doesn't?  
Needless to say the DSN I point to in the ".odbc" method is the same as the one I pass as the "driver" parameter of the "connect" method (in this case, it's the path to Snowflake's ODBC driver on Mac: /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib)

Passing the :driver option when connecting via ODBC changes the behavior to use ::ODBC::Database.new.drvconnect.  If you want to use ODBC.connect, you shouldn't pass the :driver option.  If you want to use Sequel.connect instead of Sequel.odbc, you could try:

Sequel.connect('odbc:///SnowflakeDSII?user=XXX&password=YYY')

Thanks,
Jeremy
Reply all
Reply to author
Forward
0 new messages