-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.

3
  • Please edit your question to show the actual code you're trying to use. Commented Mar 25, 2018 at 1:27
  • I don't know how to do variable substitution; that's why I am asking! Commented Mar 25, 2018 at 2:33
  • I figured out how to do it! Can someone please unmark the question as a duplicate so that I can answer it? Commented Mar 26, 2018 at 2:07

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.