Use psql --command instead of parsing stdout