Pages

Friday, December 24, 2010

Sql ,database connection

Database creation

Sample Example
require 'rubygems'
require 'mysql'
connection = Mysql.new('localhost','root','system$$','rubyclass')
response = connection.query("insert into sample(name,address) values('thyagu','chennai');")
response = connection.query("insert into sample(name,address) values('ravi','bangalore');")
response = connection.query("insert into sample(name,address) values('sameer','hyderabad');")
response = connection.query("insert into sample(name,address) values('suresh','thar desert');")
response = connection.query("insert into sample(name,address) values('yogesh','himalaya panimalai');")


puts "Db connected table created"

No comments:

Post a Comment