Fixed error in main script when using other database engine. Fixed #1166.