class UUIDField(Field):
    db_field = 'binary(16)'

def db_value(self, value):
    if value is None:
        return None
value = value.translate(None, '-')
query = SelectQuery(self.model_class, fn.UNHEX(value).alias('unhex'))
result = query.first()
value = result.unhex
return value
peewee + MySQL, How to create a custom field type that wraps SQL-built ins?