-1

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.

Andre Figueiredo
  • 12,930
  • 8
  • 48
  • 74
Mr. Hax
  • 195
  • 1
  • 1
  • 10

1 Answers1

0

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/

Mr. Hax
  • 195
  • 1
  • 1
  • 10