Fix output to file for psql and mysql
Support "AS $$" delimiter for psql