Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools2/test_sql_search.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools2/test_sql_search.py')
-rwxr-xr-xtools2/test_sql_search.py32
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()