K
klia
Hey guys;
I am trying to develop a tiny program using python to search inside sqlite
database with file extension is .db in which the program will ask users to
enter their search query and base on that it will retrieve the results But
I need the program to have some smartness in search mechanism in which the
program will guess that the user is looking for these key words in the
database.
so far i came up with this but the search ain't smart, i have to write the
full key word in order to retrieve specific information.
from pysqlite2 import dbapi2 as sqlite3
connection = sqlite3.connect('Photos.db')
memoryConnection = sqlite3.connect(':memory:')
cursor = connection.cursor()
prompt = 'Enter your search query?\n'
keyword = raw_input(prompt)
if cursor.execute('SELECT * FROM photos WHERE Tag LIKE ?',[keyword]):
print cursor.fetchall()
else:
cursor.execute('SELECT * FROM photos WHERE Date LIKE ?', [keyword])
print cursor.fetchall()
Any ideas and
thanks in advance
Reply
I am trying to develop a tiny program using python to search inside sqlite
database with file extension is .db in which the program will ask users to
enter their search query and base on that it will retrieve the results But
I need the program to have some smartness in search mechanism in which the
program will guess that the user is looking for these key words in the
database.
so far i came up with this but the search ain't smart, i have to write the
full key word in order to retrieve specific information.
from pysqlite2 import dbapi2 as sqlite3
connection = sqlite3.connect('Photos.db')
memoryConnection = sqlite3.connect(':memory:')
cursor = connection.cursor()
prompt = 'Enter your search query?\n'
keyword = raw_input(prompt)
if cursor.execute('SELECT * FROM photos WHERE Tag LIKE ?',[keyword]):
print cursor.fetchall()
else:
cursor.execute('SELECT * FROM photos WHERE Date LIKE ?', [keyword])
print cursor.fetchall()
Any ideas and
thanks in advance
Reply