Wolfgang Rohdewald <wolfgang(at)rohdewald(dot)de> writes:
> but multiline only works when using psql interactively.
I'm not much of a Python user, but doesn't Python think that leading
whitespace (particularly tabs) is significant? You may be losing
tabs if psql tries to take them as completion commands.
regards, tom lane