cancel
Showing results for 
Search instead for 
Did you mean: 

How do I connect to Sybase IQ with Ruby?

Former Member
3,943

The Sybase IQ release docs list Ruby native and DBI driver support. Details on how to connect are not listed but the page does link to the Sybase SQLAnywhere for Ruby page. So I downloaded the SQLAnywhere for Ruby driver and built the gem (installing from rubygems gave seg faults).

What I can't figure out is what the connection string should be.

The MySQL connection in DBI looks like DBI.connect("DBI:Mysql:mydbname;host=myhostname;port=myport", "myuser", "mypassword")

Using the same format for IQ only gives me 'Not connected to a database (DBI::DatabaseError)'

Any help would be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

I saw both those docs and the ones listed with the gem. It was just a matter of getting the params right by combining the port with the host name. Here is what worked for me using IQ.

DBI.connect("DBI:SQLAnywhere:DBN=mydbn;HOST=myhostname:myport", "myuser", "mypassword")

Answers (1)

Answers (1)

MarkCulp
Participant

The connect() call parameters are documented in the SQL Anywhere Ruby-DBI driver documentation page. There are also some examples on this same page.

Basically the first parameter is of the form "DBI:SQLAnywhere:<server-name>" or "DBI:SQLAnywhere:<connection-parameter-list>" where <server-name> is the name of the server to which you want to connect and <connection-parameter-list> is an semicolon separated key=value pairs (e.g. "server=myserver;dbn=mydatabase;host=myhost").