DBGraffle4 : Automatically draw SQL schema in OmniGraffle
Paul Davis wrote a script to extract the schema from a postgresql server and draw it in OmniGraffle. This is so handy you wouldn’t believe. Then his domain expired. It’s still available from The Wayback Machine however, but since that’s not indexed by google (as far as I know), I thought I’d replicate the relevant parts on my blog, to keep them alive. Mirrors of: the Python script and the AppleScript. You need both.There’s also a version of DBGraffle that gets the schema from a MySQL database, by Thomas Pan.
Here’s a complete repost of his blog entry, with all links substituted with Wayback equivalents:
General
This project is intended as a way to easily import an SQL schema into OmniGraffle. It was written for OmniGraffle 4. To the best of my knowledge it works on both OmniGraffle 4 and OmniGraffle 4 Professional. It will NOT work on any earlier version. The OmniGraffle team was nice enough to pressure me into updating a script I wrote last week to the new version so if you’re looking for something to use with OmniGraffle 3, check here for that. Its been very fluid with my web postings of this lately. If you can’t find something, hold on to your butt cause it’ll pop up somwhere eventually.
Me
Written by Paul DavisRequirements
OS X
Errrm, you kinda need this to run OmniGraffle.OmniGraffle 4
You need at least version 4.0 I tested this on the demo, and I think its working. I didn’t play around too much because I’ve been playing with the Professional version. It will NOT work on older versions, so if you were gonna ask that, you already know.
PostgreSQL
The basic principles of this should not be limited to Postgres. If you want to try extending support to other database backends, I’ll udate this so that everyone can share your wonderous accomplishment. Note: I have a very short temper for MySQL users.Python
I used AppScript for this. AppleScript is not my friend. AppleScript is not your friend. The version that I assume came on this laptop is sufficient. I don’t know if it came on this laptop or it got installed as package. However, this version is good to go. I list versions a bit further on.
AppScript
AppScript is my friend. AppScript is your friend. Use AppScript and you will be smiled upon by whichever god scares you the most. That and you won’t go bald as fast as you would using AppleScript.PyGreSQL
Mmmmm. My buddy Scott Lamb has got a project going to write some good Postgres drivers for Python. When he gets that into a working state I plan on migrating to use his drivers. Once you find the power of bind, its a bit hard to leave it.
My Versions
- OS X 10.4.3
- OmniGraffle Professional 4.1 Beta 1
- PostgreSQL 8.0.2
- Python 2.3.5
- AppScript 1.0.0
- PyGreSQL 1.33
Download
Installation
- Download DBGraffle4.py and place it somewhere safe.
- Download DBGraffle4.scpt and place it somewhere convenient
- I reccommend using Script Editor to save the *.scpt as an *.app and placing it in the dock or on the desktop. After its there, you can double click it and follow the popups.
General Information
I used the red, blue, and green highlights just to show that you can alter the default properties of objects as they are created. If you open the python script and look at the first 20 lines or so, you’ll see where you can change the defaults to your liking. I couldn’t get the line jumps to take. It seems they got a whole lot more complicated than they were in OG 3.
Related Stuff
Questions and Comments
Feel free to email me with questions and comments. I’m lonely.
Thanks
- Jeff Melloy - I swapped him laptops cause I don’t have an Apple. And he’s good at SQL.
- Joel Page - One of the Omni Graffle engineers. Gave me a hand with Omni Graffle 4
- All the open source projects that I’ve used.
Money
I don’t want any. Send something to a charity. Preferably cancer research.