Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools2/test_sql_search.py
blob: 54fc87e0accdcf08883b36a29f55716d1829aa15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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()