🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

em-mysql

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

em-mysql

0.4.2
Rubygems
Version published
Maintainers
2
Created
Source

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

== Fork comments

Can work with multiple databases.

db = Sequel.mysql config EventedMysql.databases[db] ||= EmMysql.new(config)

db2 = Sequel.mysql config2 EventedMysql.databases[db2] ||= EmMysql.new(config2)

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

FAQs

Package last updated on 25 Nov 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts