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
on 2005-12-01 00:28
on 2005-12-01 00:36
planetthoughtful wrote: > 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
on 2005-12-01 01:56
On 11/30/05, planetthoughtful <firstname.lastname@example.org> 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 2000/XP It is actually a Ruport tutorial, but everything but the last step is just getting DBI/MySQL running: http://stonecode.org:2501/stonecodeproductions/pub...
on 2005-12-01 02:00
Hi James, Thank you -- have it working now! Much warmth, planetthoughtful
on 2005-12-01 02:13
>> 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 B. 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-softw...) * SQLite (columns are untyped; available from http://sqlite.org) Please report back when successful, to help others like yourself. Cheers, Dave
on 2005-12-01 08:24
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
on 2005-12-01 22:18
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
on 2005-12-01 23:59
I'm using it on Windows, its all bundled to gether in Instant Rails: http://instantrails.rubyforge.org/ Curt
on 2005-12-02 03:58
MySql now has a Ruby section in the forums area. http://forums.mysql.com/list.php?116
on 2005-12-11 18:25
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=... 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.
on 2005-12-11 18:27
On 11/30/05, Tree D. <email@example.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. You can just use MinGW. http://www.mingw.org/ this gives you gcc and make.
on 2005-12-11 18:27
- 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
on 2005-12-11 18:27
Tree D. 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 V.