Last active
December 10, 2015 19:48
-
-
Save llaskin/4484044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_active_site_name | |
require 'pp' | |
require 'mysql2' | |
connection = Mysql2::Client.new(:host => "myhost", :username => 'myuser', :password => 'mypass') | |
insert_statement = "select value from db.table where key_name = 'foo';" | |
result = connection.query(insert_statement, :as => :array) | |
connection.close | |
pp result.to_a #result A below | |
pp result.to_a.flatten #result B below | |
pp result.to_a.flatten.to_s #result C | |
pp result.to_a.first | |
##A: [["llaskin"]] | |
##B: ["llaskin"] | |
##C: "[\"llaskin\"]" | |
##D: ["Automation Test Same Shard01-07-2013--11-59-40 Site"] | |
end | |
#db.table structure: | |
#key_name(varchar 45) | value(varchar 1024) | |
#'foo' | 'llaskin' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment