<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def db_user_exists(username):
 """Return True if the DB user already exists. """

    qry = u"""SELECT COUNT(*) FROM pg_roles where rolname = \'{username}\';"""
    output = StringIO()
    excute_query(
        qry.format(username=username),
        flags="-Aqt",
        use_sudo=True,
        stdout=output
    )
    # FIXME: is there a way to get fabric to not clutter the output
    # with "[127.0.0.1] out:" on each line?
    lines = output.getvalue().splitlines()
    return lines and lines[0].endswith('out: 1')