I'm just starting out learning Ruby, having come from a PHP background.
I've downloaded the latest stable Ruby release, and have also used the
GEM package manager to install Rails, but I'm a little confused about
how I connect Ruby to MySQL?
The only references I can find to a Ruby driver for MySQL call for
compiling, and I (and many other WinXP users, I imagine) don't have a
copy of Visual C++ with which to do that.
Is there no official supported driver for connecting Ruby to MySQL
under Windows?
Forgive the newbiness of the question, but it's been bugging me since I
installed Ruby, and given my PHP background, I sort of take being able
to connect to MySQL for granted.
I'm just starting out learning Ruby, having come from a PHP background.
I've downloaded the latest stable Ruby release, and have also used the
GEM package manager to install Rails, but I'm a little confused about
how I connect Ruby to MySQL?
The only references I can find to a Ruby driver for MySQL call for
compiling, and I (and many other WinXP users, I imagine) don't have a
copy of Visual C++ with which to do that.
Is there no official supported driver for connecting Ruby to MySQL
under Windows?
... and I (and many other WinXP users, I imagine) don't have a
copy of Visual C++
Microsoft offers a free C++ compiler .....
Some instructions for use .....
I don't think the toolkit comes with "nmake" though, so you're out of
luck w.r.t. executing a make file. You can either try to find someone
with nmake.exe to give you (illegally, I guess) or you can
hand-translate a makefile into a series of steps you can call from a
script.
I'm just starting out learning Ruby, having come from a PHP background.
I've downloaded the latest stable Ruby release, and have also used the
GEM package manager to install Rails, but I'm a little confused about
how I connect Ruby to MySQL?
The only references I can find to a Ruby driver for MySQL call for
compiling, and I (and many other WinXP users, I imagine) don't have a
copy of Visual C++ with which to do that.
Is there no official supported driver for connecting Ruby to MySQL
under Windows?
You're right there's no "official supported driver".
That is indeed the pure-Ruby MySQL driver. I think I've heard it doesn't
work with MySQL 5.
There are two other ways to connect to MySQL. One is to use the MySQL ODBC
driver (available from mysql.com) along with Ruby-DBI.
Another involves compiling MySQL, or at least finding a pre-compiled binary
that works with your version of MySQL. I don't know why they're so hard to
find at the moment. But at least you don't need to fork out for Visual
Studio to compile it: check out the following page for info on the tools you
need and how it's only half a gig of downloading:
The Instant Rails project is currently using the pure-Ruby driver, but watch
for when they move to a binary, potentially with MySQL 5. (And MySQL 5 seems
to be a real DBMS.)
On 11/30/05, Tree Dweller <x@versatechs.com> wrote:
I don't think the toolkit comes with "nmake" though, so you're out of
luck w.r.t. executing a make file. You can either try to find someone
with nmake.exe to give you (illegally, I guess) or you can
hand-translate a makefile into a series of steps you can call from a
script.
I don't think the toolkit comes with "nmake" though, so you're out of
luck w.r.t. executing a make file. You can either try to find someone
with nmake.exe to give you (illegally, I guess) or you can
hand-translate a makefile into a series of steps you can call from a
script.
I don't think the toolkit comes with "nmake" though, so you're out of
luck w.r.t. executing a make file.
I think either the Platform SDK (downloadable) does, and you need that to compile most anything on Windows anyway, or the .NET SDK does. Unfortunately both hefty downloads, and require some tweaking to get to work right.
The main problem with the downloadable toolkit is that it doesn't come with the import libraries to MSVCRT.DLL, which means most builds will fail to link. The .NET SDK comes with them, but:
- the CL.EXE that comes with .NET v1.1 is a crippled version that doesn't do optimizations.
- the one that comes with v2.0 is a complete compiler, but the import libraries link against the new MSVCRT80.DLL, which is not provided with the SDK download or anywhere else legally.
If doing Rails development, just abuse that you are provided a database layer - use SQLite3 for development, works as a charm without running the server, and use MySQL as the production server. Before deploying, use Rails Schemas to dump the development DB metadata and recreate it from scratch in the production environment. The production machine will most likely be a *nix server where the native extensions are either less painful to build, or Someone Else's Problem.
I am actually connecting without difficulty (so far?) to MySQL 5.0.16
from Ruby using the ruby-mysql package downloaded from the link in
James' message. I'm not sure if ruby-mysql supports the new features in
MySQL 5 (ie Stored Procedures, Views etc), but certainly it works with
SELECTs, and I can't see why it wouldn't work with INSERTs and UPDATEs.
The only additional step required at MySQL's end is to ensure that
you're using the OLD_PASSWORD protocol for the user you define for
connecting from Ruby.
Still, I'm kind of curious as to why Ruby doesn't have an officially
supported MySQL driver (or, is it just that it doesn't have one for
Windows)?
It's the first thing a PHP coder hoping to learn Ruby would reach for,
and it's a little disconcerting that one isn't provided in the GEM
package manager...
I'm not criticising Ruby, it just strikes me as odd.
On 12/1/05, planetthoughtful <planetthoughtful@gmail.com> wrote:
Still, I'm kind of curious as to why Ruby doesn't have an officially
supported MySQL driver (or, is it just that it doesn't have one for
Windows)?
It's the first thing a PHP coder hoping to learn Ruby would reach for,
and it's a little disconcerting that one isn't provided in the GEM
package manager...
I'm not criticising Ruby, it just strikes me as odd.