Looking for any example of making SOUNDEX queries on MySQL from SQLAlchemy, if possible at all. Any alternatives?
Asked
Active
Viewed 473 times
1 Answers
1
If all you need is to use the SOUNDEX()
function, then just use func
to generate the function expression:
session.query(func.soundex(MyModel.some_str))
If on the other hand you need the SOUNDS LIKE
operator, you can use op()
:
session.query(MyModel).\
filter(MyModel.some_str.op('SOUNDS LIKE')('Supercalifragilisticexpialidocious'))
which is equivalent to
session.query(MyModel).\
filter(func.soundex(MyModel.some_str) ==
func.soundex('Supercalifragilisticexpialidocious'))

Ilja Everilä
- 50,538
- 7
- 126
- 127