Class: TinyMysql
- Inherits:
-
Object
- Object
- TinyMysql
- Defined in:
- lib/tiny_mysql.rb,
lib/tiny_mysql/version.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#defaults_extra_file ⇒ Object
readonly
Returns the value of attribute defaults_extra_file.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#mysql_command ⇒ Object
readonly
Returns the value of attribute mysql_command.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ TinyMysql
constructor
A new instance of TinyMysql.
- #query(sql) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TinyMysql
Returns a new instance of TinyMysql.
11 12 13 14 15 16 17 18 19 |
# File 'lib/tiny_mysql.rb', line 11 def initialize( = {}) @mysql_command = [:mysql_command] || 'mysql' @defaults_extra_file = [:defaults_extra_file] @host = [:host] || 'localhost' unless @defaults_extra_file @port = [:port] @username = [:username] || 'root' unless @defaults_extra_file @password = [:password] @database = [:database] end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
9 10 11 |
# File 'lib/tiny_mysql.rb', line 9 def database @database end |
#defaults_extra_file ⇒ Object (readonly)
Returns the value of attribute defaults_extra_file.
5 6 7 |
# File 'lib/tiny_mysql.rb', line 5 def defaults_extra_file @defaults_extra_file end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/tiny_mysql.rb', line 6 def host @host end |
#mysql_command ⇒ Object (readonly)
Returns the value of attribute mysql_command.
4 5 6 |
# File 'lib/tiny_mysql.rb', line 4 def mysql_command @mysql_command end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/tiny_mysql.rb', line 7 def port @port end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/tiny_mysql.rb', line 8 def username @username end |
Instance Method Details
#query(sql) ⇒ Object
21 22 23 24 25 |
# File 'lib/tiny_mysql.rb', line 21 def query(sql) out, err, status = Open3.capture3(*cmd_with_args, :stdin_data => sql) status.success? or raise err parse(out) end |