def _fmt(key, value, template='s'):
    """ Helper SQL formatting to feed parametrized queries

    Examples:
        >>> _fmt('name', 'yogi')
        "name = %(name)s"
        >>> _fmt('id >=', 10)
        "id >= %(id)s"
    """
    ctypes = {tuple: 'in'}
    if ' ' in key:
        key, compare = key.split()
    else:
        compare = ctypes.get(type(value), '=')
    fmtd_string = '{k} {c} %({k}){t}'.format(k=key, c=compare, t=template)
    return fmtd_string