Guest User

Untitled

a guest
Aug 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. # encoding: UTF-8
  3.  
  4. # show create tables from a database
  5.  
  6. require 'mysql2'
  7.  
  8. m = Mysql2::Client.new :username => 'root', :password => '', :host => 'localhost', :database => 'dbname'
  9. result = m.query("SHOW TABLES").collect do |row|
  10. table = row['Tables_in_dbname']
  11. puts table
  12. puts m.query("SHOW CREATE TABLE #{table}").first['Create Table']
  13. puts
  14. end
  15. m.close
Add Comment
Please, Sign In to add comment