Request for comments: Ruby script that counts the length of a MySQL table name

Posted by bakerjr on Stack Overflow See other posts from Stack Overflow or by bakerjr
Published on 2010-04-23T08:53:18Z Indexed on 2010/04/23 9:03 UTC
Read the original article Hit count: 286

Filed under:
|

Hi, I'm new at ruby and I would like to ask you guys if there's something that could improve my Ruby code. Here's my script:

#!/usr/bin/ruby -w

require 'mysql'
dbh = Mysql.real_connect('localhost', 'db_user', 'password', 'db_table')
tables = dbh.query('show tables')

tables.each do |table|
    puts "#{table}" + " (" + "#{table}".length.to_s + ")"
end

I'd love to hear your comments. Thanks in advance

© Stack Overflow or respective owner

Related posts about ruby

Related posts about mysql