Automatically create database directory.

cbugg: close bug-526