import sys import codecs sys.stdout = codecs.getwriter('utf-8')(sys.stdout) from sqlite3 import dbapi2 as sqlite import re #lex = sqlite.connect('/home/pat/lang/de/lexicon.db') lex = sqlite.connect('/home/pat/lex/lex/lexicon.db') lex = lex.cursor() code1, code2 = sys.argv[1], sys.argv[2] code1, code2 = sorted((code1, code2)) c = lex.execute('select sourceterm, targetterm from lexicon where sourcecode = ? and targetcode = ?', (code1,code2)) words = [] def good(term): return \ ':' not in term \ and \ not re.match('.*[0-9].*', term) for t1, t2 in c: if good(t1) and good(t2): print t1, '\t', t2,