it's not copy pasta, it's nearly, but not quite identical code. Hmm, the parser part could be factored out , I guess. There's no include mechanisms for arbitrary sql, though there is for psql, so it would make installation a bit more finicky ...