I do a lot of web development; it's my full time job, my hobby and a means to potentially earn some money on the side. I need a set of good tools in order to make aspects of the work easier or I'd spend my entire life at odds with what I do. A good Database Management System (DBMS) tool is one such tool since database management and manipulation plays such a large part of developing any content managed website, especially for quick modifications, testing and deployment.
MySQL is my DB of choice, due to working mainly on LAMP architecture systems. The best tool by far I've found for managing MySQL databases under Mac OS X is Sequel Pro (previously CocoaMySQL).
Sequel Pro is a very streamlined and powerful program for database management, it provides the facility to add, modify and remove entire databases; supports various import and export formats for singular tables, entire databases or selected query results; allowing modification of table properties as well as inline SQL querying.
Before finding Sequel Pro I was a full-time user of PHPMyAdmin, a system which I continue to use in some instances. Sequel Pro essentially provides a desktop solution that is very similar to PHPMyAdmin, anyone who has experience using PHPMyAdmin should have no problems to adjusting to using Sequel Pro in its stead.
The image above is an annotated view of the Sequel Pro interface, the main portions of the interface that I use day-to-day are highlighted and numbered, each of the numbered areas correspond to:
- Database Selector A basic drop-down list where you can select a database to work with or add a new database.
Table Selector The list of tables in the currently selected database. If the number of tables is large enough a filter field appears at the top of this list allowing you to filter the tables based upon their names. Below the list of tables is a small section with meta-data on the currently selected table, under this is the controls for the database tables. From here we can add, remove, duplicate and truncate tables with ease (with conformation on the obviously destructive actions).
- Field Viewer/Editor This portion of the interface is controlled by whichever view is selected from the icons appearing in the application toolbar.
- Keys Viewer/Editor This area allows you to manage keys and indexes of the table you're viewing. The +/- toggle at the bottom left allows you to add and remove keys/indexes.
- Structure View (shown) Changes the view to the structure view as shown and detailed above.
- Table Contents View Switches to the table contents view.
- SQL Query Editor Switches to the SQL query editor view.
Another of the real selling points for Sequel Pro for me is the ability to easily import and export data. From the
File > Export menu you can export data in various formats,
XML being the most useful.
⌘+⇧+I invokes the import dialog which allows you to select an SQL dump or CSV of values to import into the selected database. The SQL import will obviously just run the query and update the various tables as required, the CSV import on the other hand allows you to select the table and marry rows in the CSV file to those in the table you wish to import to.
As detailed above the table structure view allows you to define the structure of the tables in the database and to set up the indexing and keys for the fields.
A nice touch available here is the ability to reorder pre-existing fields by dragging and dropping them in the relevant places and the ability to duplicate fields rather than have to re-enter details for virtually identical fields.
From there you can add, modify, duplicate and delete rows in the table, all of which you'd really expect from the table contents view.
Again, like the table structure view, you can duplicate entries to save re-entering similar data. Inserting
NULL values is as simple as hitting ^+⇧+N. Copying rows as INSERT statements is a big plus (^+⌥+⌘+C) and useful when copying singular entries between a development and live database, rather than dumping the data from a custom query.
This view allows you to enter queries and run them against the database. The editor itself has autocompletion and some niceties like smart quoting of field names.
The power here comes from the ability to store previously used queries and access recent queries via a query history. Any of the generated result sets can be exported in the previously mentioned formats for easy data filtering and export.
It's a bloody useful tool and a must for anyone working with MySQL databases under Mac OS X. It's not a silver-bullet solution of course; it doesn't do much more than PHPMyAdmin and the things it does can be replicated in PHPMyAdmin with relative ease; but then it can't be a bad thing to have lying about, especially since it's free!
Go have a play with Sequel Pro now,