A MySQL driver for DataObjects.
This driver implements the DataObjects API for the MySQL relational database.
An example of usage:
# default user (root, no password); default port (3306) ::Connection.new("mysql://host/database") # specified user, specified port ::Connection.new("mysql://user:[email protected]:8888/database") @connection = ::Connection.new("mysql://localhost/employees") @reader = @connection.create_command('SELECT * FROM users').execute_reader @reader.next!
In the future, the
Connection constructor will be able to be passed either a
DataObjects-style URL or JDBC style URL, when using do_mysql on JRuby. However,
this feature is not currently working reliably and is a known issue.
This driver is provided for the following platforms:
- Ruby MRI (1.8.6/7), 1.9: tested on Linux, Mac OS X and Windows platforms.
- JRuby 1.3.1 + (1.4+ recommended).
- Rubinius (experimental).
Additionally you should have the following prerequisites:
do_jdbcgem (shared library), if running on JRuby.
To install the gem:
gem install do_mysql
If installing the MRI/1.9/Rubinius extension on OS X and you install a version
of MySQL that was built for only a single architecture, you will need to set
sudo env ARCHFLAGS="-arch i386" gem install do_mysql
To compile and install from source:
gem install rake-compiler.
For MRI/Rubinius extensions:
- Install the
gcccompiler. On OS X, you should install XCode tools. On Ubuntu, run
apt-get install build-essential.
- Install Ruby and MySQL.
- Install the Ruby and MySQL development headers.
- On Debian-Linux distributions, you can install the following packages
- If you want to cross-compile for Windows:
- Install MinGW:
- On Debian-Linux distributions, you can install the following package
- On OS X, this can install the following package with MacPorts:
- On Debian-Linux distributions, you can install the following package with
- Then, install this driver with
(jruby -S) rake install.
- Install the
For more information, see the MySQL driver wiki page: http://wiki.github.com/datamapper/do/mysql.
Follow the above installation instructions. Additionally, you'll need:
bacongem for running specs.
YARDgem for generating documentation.
See the DataObjects wiki for more comprehensive information on installing and contributing to the JRuby-variant of this driver: http://wiki.github.com/datamapper/do/jruby.
To run specs:
To run specs without compiling extensions first:
To run individual specs:
rake spec TEST=spec/connection_spec.rb
(Note that the
rake task uses a
TEST parameter, not
SPEC. This is because
Rake::TestTask is used for executing the Bacon specs).
This code is licensed under an MIT (X11) License. Please see the