Ruby, MySQL on WinXP?

P

planetthoughtful

Hello All,

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.

Many thanks for any help!

Much warmth,

planetthoughtful
 
J

James Britt

planetthoughtful said:
Hello All,

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?

There is a pure-Ruby MySQL driver.


http://raa.ruby-lang.org/project/ruby-mysql/

might be it.


James

--

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
 
D

Dave Burt

You're right there's no "official supported driver".

James Britt offered:
There is a pure-Ruby MySQL driver.
http://raa.ruby-lang.org/project/ruby-mysql/
might be it.

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:
http://rubygarden.com/ruby/ruby?WindowsCompiler

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.)

Other options (ones that I prefer over MySQL at the moment) are:
* MS SQL Server (limited storage and memory Express Edition available free
here:
http://www.microsoft.com/sql/downloads/trial-software.mspx#EEAA)
* SQLite (columns are untyped; available from http://sqlite.org)

Please report back when successful, to help others like yourself.

Cheers,
Dave
 
T

Tree Dweller

planetthoughtful said:
... and I (and many other WinXP users, I imagine) don't have a
copy of Visual C++

Microsoft offers a free C++ compiler .....
http://msdn.microsoft.com/visualc/vctoolkit2003/

Some instructions for use .....
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vctoolkitcmd.asp

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.
 
G

Gregory Brown

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.

You can just use MinGW.
http://www.mingw.org/

this gives you gcc and make.
 
P

planetthoughtful

Hi Dave,

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.

For more info, see:
http://dev.mysql.com/doc/refman/5.0/en/old-client.html

Much warmth and many thanks,

planetthoughtful
 
L

Lou Vanek

- gcc works fine

- you don't need nmake: dsw2mak will convert MS project files to make files
gawk -f /usr/local/bin/dsw2mak *.dsw

- you don't have to recompile mysql in its entirety, just the client library

- many of the mysql .h defaults have to be tweaked to work on Windows. Specifically, files:
my_config.h
my_global.h

- a native mysql driver that links to the libmysqlclient.a file can be found at,
http://www.tmtm.org/en/mysql/ruby/

- if you have never compiled a C pgm before, I wouldn't recommend trying this
 
P

planetthoughtful

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.

Thanks to everyone who helped!

Much warmth,

planetthoughtful
 
C

Curt Hibbs

------=_Part_15458_18478127.1133473772856
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I'm using it on Windows, its all bundled to gether in Instant Rails:

http://instantrails.rubyforge.org/

Curt

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.

Thanks to everyone who helped!

Much warmth,

planetthoughtful

------=_Part_15458_18478127.1133473772856--
 
D

David Vallner

Tree said:
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.

Oh - and Cygwin helps loads too.

David Vallner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top