diff options
Diffstat (limited to 'tools2/test_sql_search.py')
-rwxr-xr-x | tools2/test_sql_search.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools2/test_sql_search.py b/tools2/test_sql_search.py new file mode 100755 index 0000000..54fc87e --- /dev/null +++ b/tools2/test_sql_search.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys +import sqlite3 + +search_word = '' +if len(sys.argv) > 1: + article = sys.argv[1] +else: + print "Use ../tools2/test_sql_search.py topic" + exit() + +print "Opening index" +dbpath = './search.db' +conn = sqlite3.connect(dbpath) + +""" +print "Searching %s" % article +search_word = '%' + article + '%' +results = conn.execute("SELECT * from articles where title like'%s'" % + search_word) +row = results.next() +while row: + print row + row = results.next() +""" + +print "Exact search:" +results = conn.execute("SELECT * from articles where title = '%s'" % + article) +print results.next() |