Ruby, MySQL on WinXP?

Discussion in 'Ruby' started by planetthoughtful, Nov 30, 2005.

  1. 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
     
    planetthoughtful, Nov 30, 2005
    #1
    1. Advertising

  2. planetthoughtful

    James Britt Guest

    planetthoughtful wrote:
    > 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
     
    James Britt, Nov 30, 2005
    #2
    1. Advertising

  3. Hi James,

    Thank you -- have it working now!

    Much warmth,

    planetthoughtful
     
    planetthoughtful, Nov 30, 2005
    #3
  4. On 11/30/05, planetthoughtful <> wrote:

    > Is there no official supported driver for connecting Ruby to MySQL
    > under Windows?


    I wrote a (breif!) tutorial for getting MySQL running via DBI on Windows 20=
    00/XP

    It is actually a Ruport tutorial, but everything but the last step is
    just getting DBI/MySQL running:

    http://stonecode.org:2501/stonecodeproductions/published/Ruport, MySQL an=
    d+Windows
     
    Gregory Brown, Nov 30, 2005
    #4
  5. planetthoughtful

    Dave Burt Guest

    > planetthoughtful wrote:
    >> 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?



    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
     
    Dave Burt, Dec 1, 2005
    #5
  6. planetthoughtful

    Tree Dweller Guest

    planetthoughtful wrote:
    > ... 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.
     
    Tree Dweller, Dec 1, 2005
    #6
  7. On 11/30/05, Tree Dweller <> 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.


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

    this gives you gcc and make.
     
    Gregory Brown, Dec 1, 2005
    #7
  8. 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
     
    planetthoughtful, Dec 1, 2005
    #8
  9. planetthoughtful

    Lou Vanek Guest

    - 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


    Tree Dweller wrote:
    > planetthoughtful wrote:
    >
    >>... 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.
     
    Lou Vanek, Dec 1, 2005
    #9
  10. 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
     
    planetthoughtful, Dec 1, 2005
    #10
  11. planetthoughtful

    Curt Hibbs Guest

    ------=_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

    On 12/1/05, planetthoughtful <> 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.
    >
    > Thanks to everyone who helped!
    >
    > Much warmth,
    >
    > planetthoughtful
    >
    >
    >


    ------=_Part_15458_18478127.1133473772856--
     
    Curt Hibbs, Dec 1, 2005
    #11
  12. planetthoughtful

    Paul Guest

    Paul, Dec 2, 2005
    #12
  13. Tree Dweller wrote:

    >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
     
    David Vallner, Dec 3, 2005
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Randy Lawrence

    mysql-ruby or ruby-mysql?

    Randy Lawrence, May 23, 2004, in forum: Ruby
    Replies:
    3
    Views:
    117
    Randy Lawrence
    May 24, 2004
  2. Bill Guindon
    Replies:
    6
    Views:
    111
    James Britt
    Sep 18, 2004
  3. Dema
    Replies:
    0
    Views:
    113
  4. Mark Meijer

    mySQL Ruby Gem and MAMP mySQL

    Mark Meijer, Feb 2, 2008, in forum: Ruby
    Replies:
    3
    Views:
    217
    louis
    Feb 3, 2008
  5. Perdikis Perdikis

    Yet another MySQL issue on WinXP

    Perdikis Perdikis, Aug 1, 2009, in forum: Ruby
    Replies:
    6
    Views:
    153
    Mits Beucannon
    Aug 1, 2009
Loading...

Share This Page