def clean_key_name(key):
    """
    Makes ``key`` a valid and appropriate SQL column name:

    1. Replaces illegal characters in column names with ``_``

    2. Prevents name from beginning with a digit (prepends ``_``)

    3. Lowercases name.  If you want case-sensitive table
    or column names, you are a bad person and you should feel bad.
    """
    result = _illegal_in_column_name.sub("_", key.strip())
    if result[0].isdigit():
        result = '_%s' % result
    if result.upper() in sql_reserved_words:
        result = '_%s' % key
    return result.lower()