[newbie] ruby-dbi

The question i have ist actually simple but yet i haven’t found out:

how to connect to a remote DB server? since all i get is a ‘‘not
reachable trough local socet’’ kind of error wich clearly would by
solved if i’d install the server locally, but that’s not a choice

so i’m asking you for help

my thank shell by on your way

Matthias Wieding-Drewes

···


/"
\ /
X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
/ \

how to connect to a remote DB server?

require ‘dbi’
dbh = DBI.connect(“DBI:Mysql:mydatabase:myhost.com”, “someuser”, “somepass”)

Substitute myhost.com with the address of your remote server. You also need to
have your remote SQL server setup to listen through a socket.

-Travis Whitton whitton@atlantic.net

that’s funny, for postgres I’ve been using this as the connection string:
“DBI:Pg:dbname=mydatabase;host=myhost.com

Are these just two equivalent forms, or is the connection string DBD dependent
after the DBI:Driver: part of the string?

···

On Sat, Feb 01, 2003 at 02:26:45AM +0900, Travis Whitton wrote:

how to connect to a remote DB server?

require ‘dbi’
dbh = DBI.connect(“DBI:Mysql:mydatabase:myhost.com”, “someuser”, “somepass”)

Substitute myhost.com with the address of your remote server. You also need to
have your remote SQL server setup to listen through a socket.


Alan Chen
Digikata Computing
http://digikata.com

Are these just two equivalent forms, or is the connection string DBD dependent
after the DBI:Driver: part of the string?

“DBI:Pg:dbname=mydatabase;host=myhost.com

It must be DBD dependent because the above listed syntax doesn’t work with
MySQL. I believe I’ve used the (“DBI:Pg:mydatabase”) syntax with Pg before,
but I could be wrong. It’s been a while…

-Travis

Alan Chen wrote:

that’s funny, for postgres I’ve been using this as the connection string:
“DBI:Pg:dbname=mydatabase;host=myhost.com

Are these just two equivalent forms, or is the connection string DBD dependent
after the DBI:Driver: part of the string?

It is DBD dependent. Well, there’s a common method that parses driver URL’s, but the
interpretation is DBD dependent.

The dbi:driver:datbase:host form applies to Mysql, msql, PostgreSQL (and without the host
part to most others too).

Those driver URLs where taken directly from Perl’s DBI, maybe not a good idea.

This works (for both Mysql and Pg):

DBI:Pg:database=mydatabase;host=myhost.com

Regards,

Michael

Are these just two equivalent forms, or is the connection string
DBD dependent
after the DBI:Driver: part of the string?

“DBI:Pg:dbname=mydatabase;host=myhost.com

It must be DBD dependent because the above listed syntax doesn’t work with
MySQL. I believe I’ve used the (“DBI:Pg:mydatabase”) syntax with Pg before,
but I could be wrong. It’s been a while…

DSN syntax is bound to be driver-dependent. More info on the MySQL syntax
for Ruby DBI is here:

http://www.kitebird.com/articles/

···

At 5:47 +0900 2/1/03, Travis Whitton wrote:

-Travis

“DBI:Pg:mydatabase” works for me with postgreSQL

Travis Whitton wrote:

···

Are these just two equivalent forms, or is the connection string DBD dependent
after the DBI:Driver: part of the string?

“DBI:Pg:dbname=mydatabase;host=myhost.com

It must be DBD dependent because the above listed syntax doesn’t work with
MySQL. I believe I’ve used the (“DBI:Pg:mydatabase”) syntax with Pg before,
but I could be wrong. It’s been a while…

-Travis

Yes, but how do you specify a non-local host?

···

On Sat, Feb 01, 2003 at 08:16:48AM +0900, Michael Garriss wrote:

“DBI:Pg:mydatabase” works for me with postgreSQL


Alan Chen
Digikata Computing
http://digikata.com