Fixes #346. Multiple databases support in management commands.

Coolio. If you fix this, I'll happily pull! :)