I am using SQLAlchemy to connect to an SQLite database which contains my words
I want to retrieve all the rows in which the value of column 'token' is a substring of a string 'myToken'
Here's how the class looks:
class Word(Base):
id = Column(Integer, primary_key=True)
token = Column(String)
The example result should be like:
myToken = "alpha"
result = ["lph", "alp",]
I've tried using various methods Some of them include:
res = session.query(Word).where(str(Word.token) in myToken).first()
Result: None
res = session.query(Word).filter(myToken.contains(str(Word.token))).first()
Result: None
res = session.query(Word).where(Word.token.like(myToken)).first()
Result: None
res = session.query(Word).filter(or_(
Word.token.like('%' + myToken),
Word.token.like(myToken + '%'),
Word.token == myToken,
)).first()
Result: None