Faker – Ruby gem

Installation

cmd>gem install faker

Basic use:

require ‘faker’

puts c=Faker::Name.name

output:

lemon arora

Fill your MYSQL DB with faker gem.

Code:

require ‘mysql’
require ‘faker’

db = Mysql::new(“localhost”, “root”, “”, “jazzezravi_development”)
i=1
while i < 1000 do

c=Faker::Name.name
c.gsub(“‘”,””)
sql = “INSERT INTO datas VALUES(#{i},’#{c}’,’0′,’0′);”
db.query(sql)
i+=1
end

For more details about faker gem –> http://faker.rubyforge.org

Advertisements

One thought on “Faker – Ruby gem

  1. I don’t know If I said it already but …Hey good stuff…keep up the good work! 🙂 I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say I’m glad I found your blog. Thanks,)

    A definite great read..Tony Brown

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s