[英]How can I access data from my other PC that is continuously running a script?
[英]How can I query and get data from my sqlite database even when my search input have similar words that is apart from each other (not continuously)
我在我的網站上有一個博客搜索 function。
這是我的搜索輸入:兒童懶惰
我的 SQLite 數據庫中有一個名為:兒童越來越懶惰的列
我使用下面的代碼(Python)來查詢數據:
many_posts0 = BlogPost.query.filter(or_((BlogPost.problem_name.ilike("%" + form.search.data + "%")),(BlogPost.text.ilike("%" + form.search.data + "%")))).order_by(BlogPost.date.desc())
但是,使用上面的代碼,我無法使用搜索輸入“兒童懶惰”顯示“兒童變得懶惰”列的結果。 如果我將搜索結果設為“children is”,則會顯示該列的數據。 我想知道我的問題是否是因為我的查詢代碼中的“ilike”。
用空格分割 sraach 字符串並加入 '%'
# split words and join with "%"
search_string = "%" + "%".join(search_data.split()) + "%"
many_posts0 = BlogPost.query.filter(or_((BlogPost.problem_name.ilike(search_string)),(BlogPost.text.ilike("%" + form.search.data + "%")))).order_by(BlogPost.date.desc())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.