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
Octocat-spinner-32 lib Remove call to old method February 08, 2010
Octocat-spinner-32 README Edited README via GitHub August 24, 2011
Octocat-spinner-32 em-mysql.gemspec version bump February 08, 2010
Octocat-spinner-32 test.rb add more tests September 13, 2008
README
This library is unmaintained. See one of the many forks instead, like em-mysqlplus: https://github.com/igrigorik/em-mysqlplus

Async MySQL driver for Ruby/EventMachine
  (c) 2008 Aman Gupta (tmm1)


Requires mysqlplus.

  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' }

Also includes a sequel async wrapper

  require 'sequel'
  require 'sequel/async'

  DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :database => 'test', ...)
  EventedMysql.settings.update(..., :on_error => proc{|e| log 'error', e })

  DB[:table].where(:field => 'value').async_update(:field => 'new value')

For more info, see the comments in lib/sequel/async.rb
Something went wrong with that request. Please try again.