Mysql and ruby 1.8

You may try this.

  1. You have to connect to Mysql with dbh
  2. Then prepare, execute and fetch

Following is a method from our project in the PHED department (Govt. of West Bengal, India)

def take_blockname #METHOD FOR TAKE BLOCK NAME FROM THE TABLE BLOCK
dbh = DBI.connect($varDataBase,$varUser,$varPass)

   #dbh = DBI.connect('dbi:Mysql:PHE1:100.100.100.1','test','')
   sql = "SELECT block_name FROM BLOCK where dcode = '#{$blockDCode}';"
   #print sql
	 dbh.prepare(sql)
	 tb = dbh.execute(sql)
	 str = tb.fetch()
	 get_block = str.to_a
	 
while(str!=nil)
  str = tb.fetch()
  get_block<<str.to_a
end	
dbh.disconnect	
#print get_block
    $cmbBlockBName.entries  = get_block  #SENDING BLOCK NAMES TO THE COMBO BOX

end #ENDING METHOD FOR TAKING BLOCK NAMES

···

On Mon, 17 Nov 2003 Matt Lawrence wrote :

On Mon, 17 Nov 2003, Stefan Schmiedl wrote:

Does anybody have the ingredients at hand to get a working
connection between Ruby 1.8 and (MySQL and PostgreSQL) on
a Windows XP box?

Install Linux? :slight_smile:

Actually, I suggest you look at the ruby-dbi package.

– Matt
Boredom isn’t the root of all evil, but it tries.