Connecting to remote Databases in Ruby DBI -


how can connect remote databases in ruby ?

i have application need connect remote host databases , read databases table , map application .

thank in advance

your question incomplete. didn't mention database. i'm assuming mysql. should show efforts.

install mysql gem http://tmtm.org/en/mysql/ruby/

gem install mysql 

now, use in ruby file.

db = mysql.new(hostname, username, password, database) 

example:

require 'mysql' db = mysql.new('209.88.228.142', 'someuser', 'exceptionalpassword', 'greatdb') 

put server's ip or host in hostname. rest of parameters self-explanatory. must allow public ip address in remote servers mysql host. example, if ip 209.88.228.142, must allow ip in mysql server.

see doc more detail.

allowing ip in database server. assuming above mentioned ip public ip, can allow access greatdb database using following command. run in db server's console.

grant on greatdb.* someuser@'209.88.228.142' identified 'exceptionalpassword'; 

note: replace username, dbname, password, host/ip appropriate values you.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -