Skip to content

Instantly share code, notes, and snippets.

@saboyutaka
Created May 21, 2018 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saboyutaka/f2858e3551c1cf00a3c64a34dc382b93 to your computer and use it in GitHub Desktop.
Save saboyutaka/f2858e3551c1cf00a3c64a34dc382b93 to your computer and use it in GitHub Desktop.
MySQLにアクセス
require 'mysql2'
require 'mysql2-cs-bind'
# Mysqlドライバの設定
db = Mysql2::Client.new(
host: 'localhost',
port: 3306,
username: 'root',
password: '',
database: 'sample',
reconnect: true,
)
result = db.xquery("SELECT * FROM infos")
infos = result.to_a
puts infos[0]["name"]
@saboyutaka
Copy link
Author

gem install mysql2 mysql2-cs-bind
してください

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment