<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_syntax(string):
 """ Check syntax of a string of PostgreSQL-dialect SQL """

    args = ["ecpg", "-o", "-", "-"]

    with open(os.devnull, "w") as devnull:
        try:
            proc = subprocess.Popen(args, shell=False,
                                    stdout=devnull,
                                    stdin=subprocess.PIPE,
                                    stderr=subprocess.PIPE,
                                    universal_newlines=True)
            _, err = proc.communicate(string)
        except OSError:
            msg = "Unable to execute 'ecpg', you likely need to install it.'"
            raise OSError(msg)
        if proc.returncode == 0:
            return (True, "")
        else:
            return (False, parse_error(err))