Python Forum
Problems creating a search engine
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems creating a search engine
#11
Hey thanks so much for helping - you are awesome - but it's not working it's still saying it's "None" for some reason!
Even when I type in an exact match.
Reply
#12
Sorry to make you test it over and over again with no result, but try this.
@app.route("/search", methods=["GET", "POST"])
def search():
    searchString = 'user'
    b = db.execute("SELECT * FROM books WHERE author LIKE :search", {'search': searchString}).fetchone()
    print(b)
    return render_template("search.html", anyVariableName=b)
Reply
#13
no problem it's going to really help when I get it - then i can study it. I learn much better that way.

It's still doing the same thing - None.
Reply
#14
anyone else see the issue? Thanks
Reply
#15
still working on the same code - haven't updated at all. Thanks guys just waiting! :)
Reply
#16
This is the only other form that I found that it might work in, if it doesn't work then I've got nothing else even after going through at least 10 various pages.
@app.route("/search", methods=["GET", "POST"])
def search():
    searchString = 'user'
    b = db.execute(f"SELECT * FROM books WHERE author LIKE %{searchString}%").fetchone()
    print(b)
    return render_template("search.html", anyVariableName=b)
Reply
#17
nope it's still coming up as None. THanks for your help!

Anyone else know why?
Reply
#18
Instead of waiting for a long time for your answer, you can also experiment with your code to find the solution.
And I'm just guessing, but I think using the fetchtone() function returns None
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#19
(Jun-15-2020, 05:55 AM)card51shor Wrote: nope it's still coming up as None. THanks for your help!

Anyone else know why?

For the same reason, you got None in the previous thread

Your SQL statement has nothing to return either due to there being nothing in the database that matches the SQL or your SQL statement is wrong.
  • Make a stand-alone python file
  • create an in-memory version of the database
  • add what you want to search for,
  • return every result to make sure it is there
  • try your search
if this doesn't work you can share this code,
everyone can run it to get the same results you are getting and be able to assist you.
Reply
#20
(Jun-15-2020, 08:36 AM)pyzyx3qwerty Wrote: Instead of waiting for a long time for your answer, you can also experiment with your code to find the solution.
And I'm just guessing, but I think using the fetchtone() function returns None

I have been for days. I can't figure out if the syntax is correct. It's very complicated just to do an easy sql search.

(Jun-15-2020, 09:37 AM)Yoriz Wrote:
(Jun-15-2020, 05:55 AM)card51shor Wrote: nope it's still coming up as None. THanks for your help!

Anyone else know why?

For the same reason, you got None in the previous thread

Your SQL statement has nothing to return either due to there being nothing in the database that matches the SQL or your SQL statement is wrong.
  • Make a stand-alone python file
  • create an in-memory version of the database
  • add what you want to search for,
  • return every result to make sure it is there
  • try your search
if this doesn't work you can share this code,
everyone can run it to get the same results you are getting and be able to assist you.

I'm not exactly sure what you mean. The data definitely exists in the table and I can search for it. I just try searching for "b" with anything that has a "b" in it and it still comes up at None.

So it's not the table I think it's the code. There's gotta be something wrong with it - there's no clear syntax on how to do it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Website with recommendation engine Bartthew 1 1,780 Jul-25-2019, 11:42 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020