From 2385830803ca8b6eaf9a2666f26c0f5586167c46 Mon Sep 17 00:00:00 2001 From: Assim Deodia Date: Sat, 14 Jun 2008 16:30:20 +0000 Subject: bug fix: dictionary.py --- diff --git a/dictionary.py b/dictionary.py index b6887c8..b962714 100644 --- a/dictionary.py +++ b/dictionary.py @@ -12,6 +12,7 @@ global __src__ global __fld__ global __debug global __numword +global __DBName global __DBTableName __root__ = "dictionary" @@ -24,6 +25,7 @@ __src__ = "source" __fld__ = "fld" __debug = True __numword = -1 +__DBName = "/tmp/las" __DBTableName = "dictionary" #Currently not used #strings which are tag in XML @@ -71,18 +73,17 @@ class dictionary: tempDict["pos"] = child.text t = ( tempDict["word"],tempDict["def"],tempDict["phnm"],tempDict["src"],tempDict["pos"] ) self.c.execute( "insert into dict values (?, ? , ?, ?, ?)", t ) - self.c.execute("select * from dict") - for row in self.c: - print row + self.conn.commit() + self.c.close() + self.conn.close() def MakeDB(self): import sqlite3 import random - salt = str(random.uniform(1, 9))[2:7] - conn = sqlite3.connect("/tmp/las" + salt) - self.c = conn.cursor() - self.c.execute('''create table dict (word text, def text, phnm text, src text, pos text)''') - + self.conn = sqlite3.connect("las.db") + self.c = self.conn.cursor() + self.c.execute('''DROP TABLE IF EXISTS dict''') + self.c.execute('''CREATE table IF NOT EXISTS dict (word text, def text, phnm text, src text, pos text)''') if __name__ == "__main__": k = dictionary("dict/k.xml") -- cgit v0.9.1