Wiki

Clone wiki

sqlalchemy / UsageRecipes / SelectUpperLike

an example of doing a case-insensitive LIKE comparison

info_table = Table('infos', engine,
        Column('pk', Integer, primary_key=True),
        Column('info', String))

info_table.create()

info_table.insert().execute(
        {'pk':1, 'info':'pk_1_data'},
        {'pk':2, 'info':'pk_2_data'},
        {'pk':3, 'info':'pk_3_data'},
        {'pk':4, 'info':'pk_4_data'},
        {'pk':5, 'info':'pk_5_data'})

select([info_table], func.upper(info_table.c.info).like('%3_DAT%')

# Prints: [(3, u'pk_3_data')]
print repr(sas_result)

Updated