forked from tmm1/em-mysql
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME
More file actions
28 lines (17 loc) · 698 Bytes
/
README
File metadata and controls
28 lines (17 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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' }