PYTHON (2.7) Question Assignment Description The searcher class found in the tex
ID: 666689 • Letter: P
Question
PYTHON (2.7) Question
Assignment Description The searcher class found in the textbook has one major drawback. Whenever the searched keywords is not found among the indexed pages, it ends up with sqllite3 Exception. This makes is almost unusable for any practical useful search application. Modify the searcher class so that instead of exiting prematurely with an Exception, the program gives a more meaningful response, like No Results Found ? Explain the reason that caused the Exception in the original code, and the solution you developed to overcome the problem.Explanation / Answer
Since index pages means unique...so that if we search index page number which is out of bounds..it will fail to search primary key with that given value in database . So , it will throw database sqlite3 exception...So inorder to void this we have use exceptions..so it will not interrupt at any moment...
Here is the example...where we can overcome sqlite3 error...
if sqlite3.search_index(buffer):
try:
buffer = buffer.strip()
cur.execute(buffer)
if buffer.lstrip().upper().startswith("SELECT"):
print cur.fetchall()
except sqlite3.Error as e:
print "No results Found!!", e.args[0]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.