Fix #571 -- Improve database engine detection.