escaping quotes in psql command for fabric script
Use pipes.quote()
to quote something that goes to the shell.
import pipesdef delete_tables(): the_command = "SELECT string_agg(table_name, ',') FROM information_schema.tables WHERE table_schema='public'" run("TABLES=`psql -U db_user -d db_name $PGDB -t --command %s`" % pipes.quote(the_command))