Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dictionary.py17
1 files changed, 9 insertions, 8 deletions
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")