def sql(c, sql, database='', port=None):
    """
    Execute some SQL as the 'postgres' user.
    """
    cmd = (
        'sudo -u postgres psql {port} --tuples-only --no-align --command="{sql}" {database}'
        .format(port='--port={}'.format(port) if port else '', sql=sql,
        database=database))
    return c.sudo(cmd, shell=False)
