def patch_for_schema(self, fn):
        schema = self.opts.schema

        f = open(fn)
        try: data = f.read()
        finally: f.close()

        if not schema:
            return data

        self._check_schema_exists(schema)

        re_path = re.compile(r'SET\s+search_path\s*(?:=|to)\s*([^;]+);', re.I)
        m = re_path.search(data)
        if m is None:
            newdata = ("SET search_path = %s;\n\n" % schema) + data
        else:
            newdata = re_path.sub("SET search_path = %s;" % schema, data)

        diff = ''.join(difflib.unified_diff(
            [r + '\n' for r in data.splitlines()],
            [r + '\n' for r in newdata.splitlines()],
            fn, fn + ".schema"))
        msg = _("""
In order to operate in the schema %s, the following changes will be
performed:\n\n%s\n\nDo you want to continue?""")
        self.confirm(msg % (schema, diff))

        return newdata
Patch a sql file to set the schema where the commands are executed.
dataset/ETHPy150Open dvarrazzo/pgxnclient/pgxnclient/commands/install.py/LoadUnload.patch_for_schema