· 7 years ago · Jan 24, 2019, 01:40 PM
1class DatabaseConnection:
2 def __init__(self):
3 self.connection = sqlite3.connect('teas.db')
4 self.connection.row_factory = dict_factory
5 self.create_table()
6
7 if self.get_records_count() == 0:
8 self.seedDB()
9
10
11
12 def create_table(self):
13 c = self.connection.cursor()
14 c.execute('''
15 CREATE TABLE IF NOT EXISTS teas (
16 id INTEGER PRIMARY KEY AUTOINCREMENT,
17 name TEXT,
18 temperature INTEGER,
19 time INTEGER
20 )
21 ''')
22 self.connection.commit()