But from within the script, I’m unable to capture this output as a
string, for example:
irb> require ‘dbi’
irb> asdf = DBI::Utils::XMLFormatter.table(dbh.select_all(“SELECT *
FROM people”))
irb> puts asdf
=> #IO:0x2c18968
[/xml_borked.rb]
I’d like to be able to use puts to output the results of the
DBI::Utils::XMLFormatter method.
But from within the script, I’m unable to capture this output as a
Any suggestions?
The XMLFormatter.table method takes four arguments. The fourth argument
specifies an IO handle to send the output. By default this is set to
STDOUT. So, your options are to either provide an IO object for the
fourth argument, or temporarily redirect STDOUT.
I should mention that this part of the dbi package has not been
refactored or properly documented via rdoc yet. We need to get on that.
I never could get it to work properly… It’s like… when I used the
fourth variable as you suggested, the component was missing.
IE:
irb> DBI::Utils::XMLFormatter.table(dbh.select_all(“SELECT *
FROM people”), nil, nil, asdf)
puts asdf
<>
</>
When I threw in the variable as the second paramater, I would get the
piece but not the … Hard to expain right now because I
have no db to test it on but at work, this is what happened… Does
this provide enough detail?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.