How do I do a "starts with" query using SQL alchemy?
python, sqlalchemy
Solution
This is the pure SQL:
SELECT * FROM table WHERE field LIKE "string%"
The SQL alchemy is:
q = ses.query(Table).filter(Table.fullFilePath.like('path%')).all()
Problem
I am learning to use SQL alchemy to connect to a mysql database. I want to pull records from the DB that start with a given string. I know that for simple equality all I need to do is this ``` queryRes = ses.query(Table).filter(Table.fullFilePath == filePath).all() result = [] ``` How do I do something like this? ``` queryRes = ses.query(Table).filter(Table.fullFilePath.startsWith(filePath)).all() result = [] ``` Maybe the query would look like this? ``` q = ses.query(Table).filter(Table.fullFilePath.like('path%')).all() ```