• home
  • forum
  • my
  • kt
  • download
  • eRuby: Using Ruby PostgreSQL and MySQL on Windows

    Author: 2007-08-25 14:58:52 From:

    If you have been following this series then you probably left off with Using Ruby and MySQL. This tutorial had parts which were specific to Linux users. The code was correct and cross platform but the means of getting MySQL drivers to work was all Linux. If you are a hardcore windows user like me you probably got a bit upset. Don't worry I did not forget it just took me awhile to find the links. I'll have to start using del.icio.us more but you are not here to read about my failing memory are you? Read on and get the files and knowledge you need.

    Windows,MySQL and Ruby

    If you are a Windows user then listen up. There are solutions for Ruby and MySQL on Windows. Roderick Von domburg has a project for this and the release along with excellent instructions are available here. Great stuff! He even shows you how to compile your own connection dll on Windows.

    Windows,PostGreSQL and Ruby

    I am a big fan of PostgreSQL database which now has a stable Windows version. Though not every shared web host has PostGreSQL enough of them do to make it worth learning about and using. So I nearly jumped out of my seat when I saw that Roderick also has done a PostGreSQL version of the Ruby windows driver. Again he has out done himself with giving instructions that are easy to follow.

    If you have the time then you may want to post and give Roderick a virtual handshake for all his hard work.

    After you have done your install run this code. You will suddenly get a feeling of freedom and excitement from knowing that you now have a very powerful alternative to PHP.


    <html>
     <head>
      <title>Welcome to eruby Test</title>
     </head>
    <body>
    <h2>eRuby mysql test</h2>
    <%
    require "mysql"
       begin
        puts Mysql::VERSION
        dbname = "sampledb"
        m = Mysql.new("localhost", "root", "")
        r = m.query("CREATE DATABASE #{dbname}")
        m.select_db(dbname)
        m.query("CREATE TABLE words
                 (
                  german varchar(30),
                  english varchar(30),
                  french varchar(30)
                 )"
                )
        m.query("INSERT INTO words VALUES('Adler', 'eagle', 'aigle')")
        m.query("INSERT INTO words VALUES('Haus', 'house', 'maison')")
        m.query("INSERT INTO words VALUES('Name', 'name', 'nom')")
        m.query("INSERT INTO words VALUES('Wal', 'whale', 'baleine')")
        m.query("GRANT ALL ON sampledb.* TO rubyuser@localhost IDENTIFIED by 'ruby'")
        m.close
       rescue=>detail
          print "<div style=\"padding:0.5em;margin:1em;border:1px solid #0000cc\">"
          print detail.backtrace.join, "\n"
          print '' + $! + "</div>", "\n"
        end
    print "Done with task"
        %>
    </body>
    </html>
     



    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      Database Related (2)
      Getting Started (7)
      Helpers (4)
      Image Manipulation (2)
      Security (4)

    New

    Hot