Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Async MySQL driver for Ruby/Eventmachine

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 README
Octocat-spinner-32 em-mysql.gemspec
Octocat-spinner-32 test.rb
README
Async MySQL driver for Ruby/EventMachine
  (c) 2008 Aman Gupta (tmm1)


Requires mysqlplus and the EM.attach patch.

  require 'em/mysql'

  # alias SQL for simpler syntax

  SQL = EventedMysql
  def SQL(query, &blk) SQL.select(query, &blk) end

  
  # setup connection details and allow 4 connections to the server

  SQL.settings.update :host => 'localhost',
                      :port => 3306,
                      :database => 'test',
                      :connections => 4
  

  # use 4 connections to execute queries in parallel

  SQL('select sleep(0.25)'){ p 'done' }
  SQL('select sleep(0.25)'){ p 'done' }
  SQL('select sleep(0.25)'){ p 'done' }
  SQL('select sleep(0.25)'){ p 'done' }
Something went wrong with that request. Please try again.