title: Creating an sqlite database search engine with python
body: <p>I have an sqlite database with 2 tables. I need to create a cgi search engine for the database, with 2 options in a drop-down menu: Name &amp; Keyword.</p>
  
  <p>If the option is Keyword, the 1st table is searched for a matching keyword (in any column). If the option is Name, the 1st column of the 2nd table is searched for an exact match. </p>
  
  <p>I have created the cgi web interface with a search box, and the drop-down menu, that saves the input search term. Now I am stuck as to how I can program my cgi script to do a search of the database based on the input term, and display the results to screen as a table. </p>
  
  <p>Below are the relevant parts of my script:</p>
  
  <pre><code>import cgi
  
  """set up the content type, open the html, title, and body"""
  
  print '&lt;form action=search.cgi&gt;'
  print '&lt;select name=\'dropdown\'&gt;'
  print   '&lt;option&gt; Name &lt;/option&gt;'
  print   '&lt;option&gt; Keyword &lt;/option&gt;'
  print '&lt;/select&gt;'
  
  print '&lt;input type=\'text\' name=\'desc\' size=\'25\'&gt;'
  print '&lt;button type="submit"&gt; Go &lt;/button&gt;'
  print '&lt;/form&gt;'
  
  args = cgi.FieldStorage()
  desc = args.getfirst("desc")
  dropdown = args.getfirst("dropdown")
  </code></pre>
  
  <p>And here is where I need help:</p>
  
  <pre><code>if dropdown == 'Keyword':
      ...
  elif dropdown == 'Name':
      ...
  </code></pre>
  
  <p>Thanks in advance for any help!</p>