test for db exists first