def build_where(condition):
    # type: (str) -> str
    '''
    Builds another part of a where clause depending on whether any other clauses
    have been used yet. Inspects global HAS_WHERE and adds either a WHERE or AND.
    '''
    global HAS_WHERE
    s = ''
    if HAS_WHERE:
        s += 'AND'
    else:
        HAS_WHERE = True
        s += 'WHERE'
    return '{0} {1}\n'.format(s, condition)
Builds another part of a where clause depending on whether any other clauses
have been used yet. Inspects global HAS_WHERE and adds either a WHERE or AND.
scripts/query_db.py