I am using the fts5 extension of sqlite3 to search through my SQLite database in python3. I know how to use fts5 with a hardcoded query:
SELECT * FROM myTable WHERE myTable MATCH 'columnName : "hardcodedstring"'
But I can't figure out how to substitute a variable into this search. I have tried the ?
syntax that can normally be used to substitute variables into a SELECT statement in python for SQLite, but that does not seem to be working.
What I need is code that will allow me to substitute a query held in a variable into a SELECT statement with fts search like the one above.
Difference From Other Question: This question is different because I am using the fts5 extension and NOT the LIKE
clause; the LIKE clause is completely DIFFERENT. The question mark syntax does not seem to work for fts as it does for the LIKE clause.
Variable substitution into such a statement can be easily done with the peewee orm module. This link provides a thorough explanation: http://charlesleifer.com/blog/using-sqlite-full-text-search-with-python/ This is a link to the docs of the module: http://docs.peewee-orm.com/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.