Ruby connection Mysql - MySql2
In the previous section we introduced the use of Ruby DBI. This section of our technology Ruby connects Mysql more efficient driver mysql2, it is also recommended to connect to MySql.
Install the mysql2 driver:
You need to configure the path to mysql_config with –with-mysql-config, such as: –with-mysql-config=/some/random/path/bin/mysql_config.
The syntax of the connection database is as follows:
Special character escaping
Calculate the number returned by the result set:
Iterative result set:
The above example runs the output as: