By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

pysqlite smart search

P: 14
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 result 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.
Expand|Select|Wrap|Line Numbers
  1. from pysqlite2 import dbapi2 as sqlite3
  3. connection = sqlite3.connect('Photos.db')
  4. memoryConnection = sqlite3.connect(':memory:')
  5. cursor = connection.cursor()
  6. prompt = 'Enter your search query?\n'
  7. keyword = raw_input(prompt)
  8. if cursor.execute('SELECT * FROM photos WHERE Tag LIKE ?',[keyword]):
  9.     print cursor.fetchall()
  10. else:
  11.     cursor.execute('SELECT * FROM photos WHERE Date LIKE ?', [keyword])
  12.     print cursor.fetchall()
Any ideas and
thanks in advance
Feb 23 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.