Guest User

Untitled

a guest
May 25th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. require 'mysql2'
  2. require 'mysql2-cs-bind'
  3.  
  4. # Mysqlドライバの設定
  5. db = Mysql2::Client.new(
  6. host: 'localhost',
  7. port: 3306,
  8. username: 'root',
  9. password: '',
  10. database: 'sample',
  11. reconnect: true,
  12. )
  13.  
  14. result = db.xquery("SELECT * FROM infos")
  15. infos = result.to_a
  16.  
  17. puts infos[0]["name"]
Add Comment
Please, Sign In to add comment