Project

mysql2xxxx

0.06
No commit activity in last 3 years
No release in over 3 years
Gives you binaries like mysql2csv, mysql2json, and mysql2xml, and Ruby classes to match.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies
 Project Readme

mysql2xxxx¶ ↑

Binaries¶ ↑

mysql2csv --user=dbuser --password=dbpassword --database=dbname --execute="select * from automobile_makes"
mysql2json --user=dbuser --password=dbpassword --database=dbname --execute="select * from automobile_makes"
mysql2xml --user=dbuser --password=dbpassword --database=dbname --execute="select * from automobile_makes"

To see all options

mysql2csv --help

Ruby¶ ↑

a = Mysql2xxxx::JSON.new :user => 'dbuser', :password => 'dbpassword', :database => 'dbname', :execute => "select * from automobile_makes"
a.to_stdout                                     # write it directly to $stdout
puts a.to_s                                     # get a string
a.to_path('/tmp/outfile.json')                  # write it to a file at this path
a.to_file(File.open('/tmp/outfile.json', 'w'))  # write it to a file handle

Note also that if you're running it inside a Rails application, it will default to the ActiveRecord connection config.

a = Mysql2xxxx::JSON.new :execute => "select * from automobile_makes"  # no need to specify user, etc. because it's taken from ActiveRecord

Well-formedness¶ ↑

  • CSV output depends on FasterCSV to_csv

  • JSON output depends on Florian Frank's JSON JSON.generate

  • XML output is written manually, but looks like the output of mysql [hyphen][hyphen]xml

Copyright 2011 Seamus Abshere