Refactored code; organized letter and word metrics
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
import os.path
|
||||
import sqlite3
|
||||
|
||||
class Storage:
|
||||
def __init__(self, dbFile):
|
||||
self.__dbFile = dbFile
|
||||
self.__initialize()
|
||||
self.__con = None
|
||||
self.__cur = None
|
||||
|
||||
def __initialize(self):
|
||||
self._createDatabase()
|
||||
|
||||
def _createDatabase(self):
|
||||
pass
|
||||
|
||||
def _destroyDatabase(self):
|
||||
pass
|
||||
|
||||
def connect(self):
|
||||
self.__con = sqlite3.connect(self.__dbFile)
|
||||
self.__cur = self.__con.cursor()
|
||||
return self.__cur
|
||||
|
||||
def commit(self, doClose=True):
|
||||
self.__con.commit()
|
||||
if doClose:
|
||||
self.__cur.close()
|
||||
self.__con.close()
|
||||
|
||||
def recreateDatabase(self):
|
||||
self._destroyDatabase()
|
||||
self._createDatabase()
|
||||
|
Reference in New Issue
Block a user