def __init__(self, length, **kwargs):
    if kwargs.get('collate'):
        if kwargs['collate'].upper() not in ['BINARY', 'NOCASE', 'RTRIM']:
            raise TypeError('%s is not a valid SQLite collation' % kwargs[
                'collate'])
self.collation = kwargs.pop('collate').upper()
super(CI_String, self).__init__(length=length, **kwargs)

@compiles(CI_String, 'sqlite')
def compile_ci_string(element, compiler, **kwargs):
    base_visit = compiler.visit_string(element, **kwargs)
if element.collation:
    return '%s COLLATE %s' % (base_visit, element.collation)
else:
    return base_visit
Case insensitive string columns in SQLAlchemy?