diff --git a/soitool/database.py b/soitool/database.py index bd5078c92fd97c035a54a0813db197e58d6ab531..a797c0e612eeb3537062d4d32a7f3804a9fdc56f 100644 --- a/soitool/database.py +++ b/soitool/database.py @@ -21,14 +21,13 @@ class Database(): """Holds connection to database.""" def __init__(self): - """Connect to existing db if found, creates new db if not.""" + """Connect to existing db if found, create new db if not.""" db_exists = os.path.exists(DBPATH) if db_exists: - print('connecting to existing DB.') + print('Connecting to existing DB.') self.conn = sqlite3.connect(DBPATH) print('DB-connection established.') - self.conn.row_factory = sqlite3.Row # Enables row['columnName'] else: print('Creating new DB.') @@ -37,9 +36,8 @@ class Database(): print('DB created.') self.fill_tables() print('Tables filled with data.') - self.conn.row_factory = sqlite3.Row # Enables row['columnName'] - self.categories = self.get_categories() + self.conn.row_factory = sqlite3.Row # Enables row['columnName'] def create_tables(self): """Create tables CodeBook, CategoryWords and ByHeart.""" @@ -103,7 +101,7 @@ class Database(): def get_categories(self): """ - Retrieve all categories from table CategoryWords. + Retrieve all categories from DB-table CategoryWords. Returns ------- @@ -117,6 +115,3 @@ class Database(): categories.append(row['Category']) return categories - - -# TEMP = Database() diff --git a/test/test_database.py b/test/test_database.py index 7edf8e8e3ecb0ea968aa99c2782abd0c2913a778..6b52382e7210ee6da3fd4cb593c153db83e077e8 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -13,7 +13,7 @@ class DatabaseTest(unittest.TestCase): Parameters ---------- unittest : Testcase - Used to subclass + DatabaseTest is subclass of TestCase """ def setUp(self): @@ -31,7 +31,7 @@ class DatabaseTest(unittest.TestCase): f = open(file_path, "r", encoding="utf-8") file_content = f.read() - # Retrieve number of expressions and expressions from file: + # Retrieve expressions from file: expressions = file_content.split("\n")[:-1] # ignore bottom line no_of_expr = len(expressions)