
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
= ruby-mysql
== Description
MySQL connector for Ruby.
== Installation
ruby setup.rb
=== Gem Installation
gem install ruby-mysql
== Features/Problems
Ruby だけで書かれているのでコンパイル不要です。
Ruby 1.9.x の M17N に対応しています。
MySQL/Ruby 2.8.x とほぼ互換があります。
== Synopsis
使用例:
my = Mysql.connect('hostname', 'username', 'password', 'dbname') my.query("select col1, col2 from tblname").each do |col1, col2| p col1, col2 end stmt = my.prepare('insert into tblname (col1,col2) values (?,?)') stmt.execute 123, 'abc'
== Incompatible with MySQL/Ruby 2.8.x
Ruby 1.8.x ではシフトJISのような安全でないマルチバイト文字セットに対して Mysql#escape_string を使用すると例外が発生します。
いくつかのメソッドがありません: Mysql#debug, Mysql#change_user, Mysql#create_db, Mysql#drop_db, Mysql#dump_debug_info, Mysql#ssl_set, Mysql#reconnect
Mysql#options でサポートしているオプションは次のものだけです: Mysql::INIT_COMMAND, Mysql::OPT_CONNECT_TIMEOUT, Mysql::OPT_LOCAL_INFILE, Mysql::OPT_READ_TIMEOUT, Mysql::OPT_WRITE_TIMEOUT, Mysql::SET_CHARSET_NAME. これら以外を指定すると "option not implementted" という warning が標準エラー出力に出力されます。
Mysql#use_result は Mysql#store_result と同じです。つまりサーバーから一気に結果セットを読み込みます。
== Improvement from MySQL/Ruby 2.8.x
Ruby 1.9.x の M17N に対応しています。 mysqld へのクエリ文字列やプリペアドステートメントで与える値は mysqld との接続の文字コードに自動的に変換されます。 mysqld からの結果文字列は接続文字コードとして取り出されます。
Mysql::Result, Mysql::Stmt が Enumerable を include しています。
ブロックなしの Mysql::Result#each, each_hash Mysql::Stmt#each, each_hash が Enumerator を返します。
Mysql#charset= で接続 charset を指定できます。
Mysql::Error だけでなく、エラー種別ごとにエラークラスが用意されてます。たとえば、構文エラーの場合は Mysql::ServerError::ParseError など。これらのエラーは Mysql::Error の継承クラスです。
== Copyright
Author :: TOMITA Masahiro tommy@tmtm.org Copyright :: Copyright (c) 2009-2012 TOMITA Masahiro License :: Ruby's
FAQs
Unknown package
We found that ruby-mysql-ext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.