Module: BitGirder::MySql
Constant Summary
collapse
- @@mysql =
The 3p library we’re working on top of
Mysql
Core::BitGirderMethods::PARAM_TYPE_ARG, Core::BitGirderMethods::PARAM_TYPE_ENVVAR, Core::BitGirderMethods::PARAM_TYPE_KEY
Class Method Summary
collapse
argv_to_argh, check_fail_prefix, class_name_to_sym, code, compares_to, console, ext_to_class_name, ext_to_sym, has_env, has_key, has_keys, nonnegative, not_nil, positive, raisef, set_from_key, set_var, split_argv, sym_to_cli_switch, sym_to_ext_id, to_bool, unpack_argv_array, unpack_argv_hash, warn
Class Method Details
.connect(*argv) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/bitgirder/mysql.rb', line 22
def self.connect( *argv )
case argv.size
when 0 then raise "Need connect args"
when 1
case argv[ 0 ]
when Hash then connect_from_hash( argv[ 0 ] )
else @@mysql.connect( *argv ) end
else raise ArgumentError, "Unexpected argv: #{argv}"
end
end
|
.connect_from_hash(h) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/bitgirder/mysql.rb', line 14
def self.connect_from_hash( h )
flattened = h.values_at( :host, :user, :password, :db, :port, :socket )
flattened << ( h[ :flag ] || 0 )
@@mysql.connect( *flattened )
end
|
.flush_privileges(db) ⇒ Object
49
50
51
52
53
|
# File 'lib/bitgirder/mysql.rb', line 49
def self.flush_privileges( db )
not_nil( db, :db )
db.query( "flush privileges" )
end
|
.open(*argv) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/bitgirder/mysql.rb', line 38
def self.open( *argv )
mysql = connect( *argv )
begin
yield( mysql )
ensure
mysql.close
end
end
|
.quote(str) ⇒ Object
55
56
57
|
# File 'lib/bitgirder/mysql.rb', line 55
def self.quote( str )
@@mysql.quote( str )
end
|