RDO MySQL Driver
This is the MySQL driver for RDO—Ruby Data Objects.
Refer to the RDO project README for full usage information.
Installation
Via rubygems:
$ gem install rdo-mysql
Or add this line to your application's Gemfile:
gem "rdo-mysql"
And then execute:
$ bundle
Usage
require "rdo-mysql"
conn = RDO.connect("mysql://user:pass@localhost/db_name?encoding=utf-8")
Type support
The following table lists the way MySQL types are mapped to Ruby types:
MySQL Type | Ruby Type | Notes |
---|---|---|
NULL | NilClass | |
INT, TINYINT, SMALLINT, MEDIUMINT, BIGINT, INT | Fixnum | Ruby may use a Bignum of required |
CHAR, VARCHAR | String | The encoding specified on the connection is used |
TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT | String | The encoding specified on the connection is used |
BLOB, TINYBLOB, MEDIUMBLOB, LONGBLOB | String | The encoding is set to ASCII-8BIT/BINARY |
BINARY, VARBINARY | String | The encoding is set to ASCII-8BIT/BINARY |
FLOAT, DOUBLE | Float | |
DECIMAL/NUMERIC | BigDecimal | |
DATE | Date | |
DATETIME, TIMESTAMP | DateTime | MySQL does not store or return a time zone; the system time zone is used |
SET | Set | MySQL does not allow values containing commas to be included in a SET |
Prepared statements
MySQL, in theory supports prepared statements. But really you would not want to use them. There are still a number of known limitations with MySQL prepared statements, as outlined here:
- http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statement-problems.html
- http://dev.mysql.com/doc/refman/5.1/en/c-api-prepared-statement-problems.html
- http://dev.mysql.com/doc/refman/5.5/en/c-api-prepared-statement-problems.html
rdo-mysql uses RDO's emulated prepared statement support instead. If people shout loud enough that they'd prefer to use MySQL's problematic prepared statements anyway, I'll implement them.
Contributing
If you find any bugs, please send a pull request if you think you can fix it, or file in an issue in the issue tracker.
When sending pull requests, please use topic branches—don't send a pull request from the master branch of your fork.
Contributors will be credited in this README.
Copyright & Licensing
Written by Chris Corbyn.
Licensed under the MIT license. See the LICENSE file for full details.