Ruby: mysql2omnigraffle
I’ve finally put mysql2omnigraffle up on RubyForge. It’s a Ruby script to visually represent the structure and relationships of MySQL tables in OmniGraffle and at the moment it is very much in development.
If you look at the code you’ll see that it contains methods for handling OmniGraffle communication using both RubyOSA and appscript. That’s because they both seem to have their own strengths and weaknesses and I can’t yet tell which is more suited for this task. Until that time, parallel development with both.
Usage
Call the script with the following options:
~/: ruby mysql2omnigraffle.rb -t db_table_name -h db_host -u db_username -p db_password
Current status
- Reads tables from a MySQL database.
- Creates shape objects in OmniGraffle for tables and columns.
- Displays the tables in a linear format down the OmniGraffle canvas.
Needed
- Grouping within OmniGraffle to group table header shapes and table column shapes together.
- Foreign key relationships indicated between tables in some way.
- A better layout process within the OmniGraffle canvas.
Command-line parameters to define database, uname, pword, etc.- Remove OmniGraffle 4 hard-coding, get working with OmniGraffle 5.
- Everything else?
If you’re interested in helping out and relish the opportunity to delve into the guts of raw OmniGraffle apple events, please do get in touch.
4 Responses to “Ruby: mysql2omnigraffle”

tommy responded on 18 Mar 2008 at 5:35 pm #
awesome! this is a great tool!
chris responded on 18 Mar 2008 at 6:12 pm #
Thanks! Though technically it’s a great idea within an alright tool that needs a lot of work still but it’s getting there. If only I could figure out how to group objects in OG….
Gregg Pollack responded on 20 Mar 2008 at 6:02 pm #
Tried this, installed the gems, I get this when I run:
mysql2omnigraffle.rb:55:in `generate_via_rbosa’: uninitialized constant OSA::OmniGraffle4 (NameError)
from mysql2omnigraffle.rb:45:in `generate’
from mysql2omnigraffle.rb:236
Any ideas?
chris responded on 20 Mar 2008 at 6:31 pm #
Hmm, let’s start with the obvious ones then:
You’re running the script from the command line (and not from within Rails, for instance)?
You’ve got OmniGraffle 4 installed (it doesn’t yet work with OmniGraffle 5)? If you have OG 4 Professional you’ll need to change the name of the app in this script to reflect that.
The rubyosa gem is installed and the current version is 0.4.0?
If all those things are good-to-go, please try this in IRB:
irb(main):> require 'rubygems'
irb(main):> require 'rbosa'
irb(main):> x = OSA.app( "OmniGraffle\ 4" )
irb(main):> y = x.make( OSA::OmniGraffle4::Document, :with_properties => {:name => "test"} )
If everything in your set-up is good, then that ought to tell OG4 to create a new blank doc ad display something like this in IRB:
<OSA::OmniGraffle4::Document:0xaa591a0 desc="'obj '{ 'from':'null'(), 'want':'docu', 'form':'name', 'seld':'utxt'("test") }">
Can you give that a try and let me know what it reports?