Hrm. I could somehow wrap psql_cmd and extras in an escape routine perhaps ... is that what you were thinking?